Browse Source

Jan 05 : Updated 'agriculture_management_odoo'

pull/231/head
AjmalCybro 2 years ago
parent
commit
d88457ce1e
  1. 2
      agriculture_management_odoo/__manifest__.py
  2. 6
      agriculture_management_odoo/doc/RELEASE_NOTES.md
  3. 1
      agriculture_management_odoo/models/animal_rental.py
  4. 3
      agriculture_management_odoo/models/crop_requests.py
  5. 3
      agriculture_management_odoo/models/pest_request.py
  6. 2
      agriculture_management_odoo/views/menu_action.xml
  7. 24
      agriculture_management_odoo/wizard/crop_report_wiz.py
  8. 23
      agriculture_management_odoo/wizard/pest_report_wiz.py

2
agriculture_management_odoo/__manifest__.py

@ -21,7 +21,7 @@
############################################################################# #############################################################################
{ {
'name': 'Agriculture Management Odoo', 'name': 'Agriculture Management Odoo',
'version': '16.0.1.0.0', 'version': '16.0.2.0.0',
'summary': 'Agriculture Management Odoo', 'summary': 'Agriculture Management Odoo',
'sequence': 4, 'sequence': 4,
'description': """Agriculture Management Odoo, Agriculture, Farmers, Farming, Crops, Farm, Seeds, Farm Management""", 'description': """Agriculture Management Odoo, Agriculture, Farmers, Farming, Crops, Farm, Seeds, Farm Management""",

6
agriculture_management_odoo/doc/RELEASE_NOTES.md

@ -5,3 +5,9 @@
#### ADD #### ADD
- Initial commit for agriculture_management_odoo - Initial commit for agriculture_management_odoo
#### 19.11.2022
#### Version 16.0.2.0.0
#### UPDT
- Updated

1
agriculture_management_odoo/models/animal_rental.py

@ -27,6 +27,7 @@ class AnimalRental(models.Model):
_name = 'animal.rental' _name = 'animal.rental'
_inherit = ['mail.thread', 'mail.activity.mixin'] _inherit = ['mail.thread', 'mail.activity.mixin']
_description = 'Animal Rental' _description = 'Animal Rental'
_rec_name = 'animal_id'
animal_id = fields.Many2one('animal.details', string='Animal', animal_id = fields.Many2one('animal.details', string='Animal',
required=True, tracking=True) required=True, tracking=True)

3
agriculture_management_odoo/models/crop_requests.py

@ -118,5 +118,6 @@ class CropAnimals(models.Model):
dec = fields.Many2one('crop.requests') dec = fields.Many2one('crop.requests')
animal_id = fields.Many2one('animal.details', string='Animal', animal_id = fields.Many2one('animal.details', string='Animal',
tracking=True) tracking=True,
domain=[('state', '=', 'available')])
qty = fields.Integer(string='Quantity') qty = fields.Integer(string='Quantity')

3
agriculture_management_odoo/models/pest_request.py

@ -47,7 +47,8 @@ class PestRequests(models.Model):
self: self.env.user.company_id.currency_id) self: self.env.user.company_id.currency_id)
pest_quantity = fields.Integer(string='Pest Quantity', required=True, pest_quantity = fields.Integer(string='Pest Quantity', required=True,
tracking=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', total_cost = fields.Float(string='Total Cost',
compute='_compute_total_cost', store=True, compute='_compute_total_cost', store=True,
tracking=True) tracking=True)

2
agriculture_management_odoo/views/menu_action.xml

@ -29,7 +29,7 @@
</record> </record>
<record id="action_animal_rental" model="ir.actions.act_window"> <record id="action_animal_rental" model="ir.actions.act_window">
<field name="name">Vehicle Rental</field> <field name="name">Animal Rental</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">animal.rental</field> <field name="res_model">animal.rental</field>
<field name="view_mode">tree,form,kanban</field> <field name="view_mode">tree,form,kanban</field>

24
agriculture_management_odoo/wizard/crop_report_wiz.py

@ -19,7 +19,9 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from odoo import fields, models
from odoo import fields, models, _
from odoo.exceptions import UserError
class CropReport(models.TransientModel): class CropReport(models.TransientModel):
@ -41,9 +43,25 @@ class CropReport(models.TransientModel):
crop_requests.seed_id = seed_details.id crop_requests.seed_id = seed_details.id
inner join location_details ON inner join location_details ON
crop_requests.location_id = location_details.id""" 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: if self.date_from and self.date_to:
ret = ret + """ where crop_requests.request_date > '""" + str( ret = ret + """ where crop_requests.request_date >= '""" + str(
self.date_from) + """' AND crop_requests.request_date < '""" + str( self.date_from) + """' AND crop_requests.request_date <= '""" \
+ str(
self.date_to) + """'""" self.date_to) + """'"""
self.env.cr.execute(ret) self.env.cr.execute(ret)
record = self.env.cr.fetchall() record = self.env.cr.fetchall()

23
agriculture_management_odoo/wizard/pest_report_wiz.py

@ -19,7 +19,8 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from odoo import fields, models from odoo import fields, models, _
from odoo.exceptions import UserError
class CropReport(models.TransientModel): 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 res_partner on pest_request.farmer_id = res_partner.id
inner join crop_requests on crop_requests.id = pest_request.crop_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""" 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: if self.date_from and self.date_to:
ret = ret + """ where crop_requests.request_date > '""" + str( ret = ret + """ where crop_requests.request_date >= '""" + str(
self.date_from) + """' AND crop_requests.request_date < '""" + str( self.date_from) + """' AND crop_requests.request_date <= '"""\
+ str(
self.date_to) + """'""" self.date_to) + """'"""
self.env.cr.execute(ret) self.env.cr.execute(ret)
record = self.env.cr.fetchall() record = self.env.cr.fetchall()
print(record)
data = { data = {
'form': self.read()[0], 'form': self.read()[0],
'date_to': self.date_to, 'date_to': self.date_to,

Loading…
Cancel
Save