diff --git a/agriculture_management_odoo/__manifest__.py b/agriculture_management_odoo/__manifest__.py index 26b721548..cff602dfb 100644 --- a/agriculture_management_odoo/__manifest__.py +++ b/agriculture_management_odoo/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { 'name': 'Agriculture Management Odoo', - 'version': '16.0.1.0.0', + 'version': '16.0.2.0.0', 'summary': 'Agriculture Management Odoo', 'sequence': 4, 'description': """Agriculture Management Odoo, Agriculture, Farmers, Farming, Crops, Farm, Seeds, Farm Management""", diff --git a/agriculture_management_odoo/doc/RELEASE_NOTES.md b/agriculture_management_odoo/doc/RELEASE_NOTES.md index 70b6485bf..13dd51295 100644 --- a/agriculture_management_odoo/doc/RELEASE_NOTES.md +++ b/agriculture_management_odoo/doc/RELEASE_NOTES.md @@ -5,3 +5,9 @@ #### ADD - Initial commit for agriculture_management_odoo + +#### 19.11.2022 +#### Version 16.0.2.0.0 +#### UPDT +- Updated + diff --git a/agriculture_management_odoo/models/animal_rental.py b/agriculture_management_odoo/models/animal_rental.py index b52e5989c..30f580951 100644 --- a/agriculture_management_odoo/models/animal_rental.py +++ b/agriculture_management_odoo/models/animal_rental.py @@ -27,6 +27,7 @@ class AnimalRental(models.Model): _name = 'animal.rental' _inherit = ['mail.thread', 'mail.activity.mixin'] _description = 'Animal Rental' + _rec_name = 'animal_id' animal_id = fields.Many2one('animal.details', string='Animal', required=True, tracking=True) diff --git a/agriculture_management_odoo/models/crop_requests.py b/agriculture_management_odoo/models/crop_requests.py index 9f1ecabe0..509d3fdb2 100644 --- a/agriculture_management_odoo/models/crop_requests.py +++ b/agriculture_management_odoo/models/crop_requests.py @@ -118,5 +118,6 @@ class CropAnimals(models.Model): dec = fields.Many2one('crop.requests') animal_id = fields.Many2one('animal.details', string='Animal', - tracking=True) + tracking=True, + domain=[('state', '=', 'available')]) qty = fields.Integer(string='Quantity') diff --git a/agriculture_management_odoo/models/pest_request.py b/agriculture_management_odoo/models/pest_request.py index e6e0870ec..f35f5b803 100644 --- a/agriculture_management_odoo/models/pest_request.py +++ b/agriculture_management_odoo/models/pest_request.py @@ -47,7 +47,8 @@ class PestRequests(models.Model): self: self.env.user.company_id.currency_id) pest_quantity = fields.Integer(string='Pest Quantity', required=True, tracking=True) - pest_cost = fields.Float(string='Pest Cost', required=True, tracking=True) + pest_cost = fields.Float(string='Pest Cost', required=True, + tracking=True, related='pest_id.pest_cost') total_cost = fields.Float(string='Total Cost', compute='_compute_total_cost', store=True, tracking=True) diff --git a/agriculture_management_odoo/views/menu_action.xml b/agriculture_management_odoo/views/menu_action.xml index 403c7701e..53e7917c6 100644 --- a/agriculture_management_odoo/views/menu_action.xml +++ b/agriculture_management_odoo/views/menu_action.xml @@ -29,7 +29,7 @@ - Vehicle Rental + Animal Rental ir.actions.act_window animal.rental tree,form,kanban diff --git a/agriculture_management_odoo/wizard/crop_report_wiz.py b/agriculture_management_odoo/wizard/crop_report_wiz.py index ab6635424..bf9e56bba 100644 --- a/agriculture_management_odoo/wizard/crop_report_wiz.py +++ b/agriculture_management_odoo/wizard/crop_report_wiz.py @@ -19,7 +19,9 @@ # If not, see . # ############################################################################# -from odoo import fields, models + +from odoo import fields, models, _ +from odoo.exceptions import UserError class CropReport(models.TransientModel): @@ -41,9 +43,25 @@ class CropReport(models.TransientModel): crop_requests.seed_id = seed_details.id inner join location_details ON crop_requests.location_id = location_details.id""" + + today = fields.Date.today() + + if self.date_from: + if self.date_from > today: + raise UserError( + _('You could not set the start date or the end date in the future.')) + if self.date_to: + if self.date_to > today: + raise UserError( + _('You could not set the start date or the end date in the future.')) + if self.date_from >= self.date_to: + raise UserError( + _('The start date must be inferior to the end date.')) + if self.date_from and self.date_to: - ret = ret + """ where crop_requests.request_date > '""" + str( - self.date_from) + """' AND crop_requests.request_date < '""" + str( + ret = ret + """ where crop_requests.request_date >= '""" + str( + self.date_from) + """' AND crop_requests.request_date <= '""" \ + + str( self.date_to) + """'""" self.env.cr.execute(ret) record = self.env.cr.fetchall() diff --git a/agriculture_management_odoo/wizard/pest_report_wiz.py b/agriculture_management_odoo/wizard/pest_report_wiz.py index 6045cb56e..ccc49d7a1 100644 --- a/agriculture_management_odoo/wizard/pest_report_wiz.py +++ b/agriculture_management_odoo/wizard/pest_report_wiz.py @@ -19,7 +19,8 @@ # If not, see . # ############################################################################# -from odoo import fields, models +from odoo import fields, models, _ +from odoo.exceptions import UserError class CropReport(models.TransientModel): @@ -36,13 +37,27 @@ class CropReport(models.TransientModel): inner join res_partner on pest_request.farmer_id = res_partner.id inner join crop_requests on crop_requests.id = pest_request.crop_id inner join pest_details on pest_details.id = pest_request.pest_id""" + + today = fields.Date.today() + if self.date_from: + if self.date_from > today: + raise UserError( + _('You could not set the start date or the end date in the future.')) + if self.date_to: + if self.date_to > today: + raise UserError( + _('You could not set the start date or the end date in the future.')) + if self.date_from >= self.date_to: + raise UserError( + _('The start date must be inferior to the end date.')) + if self.date_from and self.date_to: - ret = ret + """ where crop_requests.request_date > '""" + str( - self.date_from) + """' AND crop_requests.request_date < '""" + str( + ret = ret + """ where crop_requests.request_date >= '""" + str( + self.date_from) + """' AND crop_requests.request_date <= '"""\ + + str( self.date_to) + """'""" self.env.cr.execute(ret) record = self.env.cr.fetchall() - print(record) data = { 'form': self.read()[0], 'date_to': self.date_to,