diff --git a/i18n/es_AR.po b/i18n/es_AR.po index 728e20d61d7628dbf217d2846ad393b74afc61b3..4690eba737392d8d65cfbe8235bd67ca303b684c 100644 --- a/i18n/es_AR.po +++ b/i18n/es_AR.po @@ -374,6 +374,16 @@ msgstr "ID" msgid "Inventory Locations" msgstr "Ubicaciones de inventario" +#. module: citrux_stock +#: model:ir.model,name:citrux_stock.model_account_invoice +msgid "Invoice" +msgstr "Factura" + +#. module: citrux_stock +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__invoiced_weight +msgid "Invoiced Weight" +msgstr "KGs Facturados" + #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location____last_update #: model:ir.model.fields,field_description:citrux_stock.field_product_season____last_update @@ -437,6 +447,11 @@ msgstr "El valor de Longitud deberá ser entre -180 y 180" msgid "Name" msgstr "Nombre" +#. module: citrux_stock +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__picked_weight +msgid "Picked Weight" +msgstr "KGs Remitidos" + #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_sale_order_line__plantation_id msgid "Plantation" @@ -492,6 +507,11 @@ msgstr "Rendimiento" msgid "Production Unit" msgstr "Unidad Productiva" +#. module: citrux_stock +#: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__production +msgid "Production per Plant" +msgstr "Rendimiento por Planta" + #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_stock_warehouse__renspa msgid "RENSPA" diff --git a/models/__init__.py b/models/__init__.py index f7079430cd7dec1bb000e494bdaf2ec21d0312da..2dfa2318e93cdf78c1755788c0420a0a03c94119 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,6 +1,7 @@ from . import ( product_product, product_season, + product_template, sale_order_line, season_product_location_line, stock_location, diff --git a/models/product_product.py b/models/product_product.py index ac77583f832f929a77cc282c4f6c041d905d627f..2a3349d4a452b9e950361c40b12d12526ef5ce90 100644 --- a/models/product_product.py +++ b/models/product_product.py @@ -13,6 +13,7 @@ class ProductImplantationLocation(models.Model): ) location_id = fields.Many2one('stock.location', required=True, string='Product Location') plants = fields.Integer(string="Plants") + production = fields.Integer(string="Production per Plant") @api.multi def name_get(self): diff --git a/models/product_template.py b/models/product_template.py new file mode 100644 index 0000000000000000000000000000000000000000..994a78668eda00c1ca4f3a4eec3585494b75d115 --- /dev/null +++ b/models/product_template.py @@ -0,0 +1,11 @@ +from odoo import api, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + @api.model + def default_get(self, fields): + res = super(ProductTemplate, self).default_get(fields) + res.update({'invoice_policy': 'delivery'}) + return res diff --git a/models/sale_order_line.py b/models/sale_order_line.py index 6a29b35976aef07261d68bfd772bed5cb04a355c..7e48e4c54f8e978db6bbe0cb9560520e93abbf1b 100644 --- a/models/sale_order_line.py +++ b/models/sale_order_line.py @@ -9,7 +9,7 @@ class SaleOrderLine(models.Model): @api.onchange('plantation_id') def onchange_plantation(self): if self.plantation_id: - self.product_uom_qty = 1 + self.product_uom_qty = self.plantation_id.production * self.plantation_id.plants self.product_id = self.plantation_id.product_id invoice_status = [('invoice_status', '!=', 'no')] sale_order_lines = self.env['sale.order.line'].search(invoice_status) @@ -37,7 +37,11 @@ class SaleOrder(models.Model): res = super(SaleOrder, self).action_confirm() for rec in self.order_line: if rec.plantation_id: - season = self.env['product.season'].search([('starting_date', '<=', rec.create_date), ('ending_date', '>=', rec.create_date)]) + season = self.env['product.season'].search([ + ('starting_date', '<=', self.validity_date), + ('ending_date', '>=', self.validity_date) + ]) + season.write({ 'season_line_ids': [(0, 0, { 'product_implantation_location_id': rec.plantation_id.id, diff --git a/models/season_product_location_line.py b/models/season_product_location_line.py index bc94daab75b94cfecf1490a220467098e50d6c60..72269c9efbcf647220c105316afb0a1cadc1ff1f 100644 --- a/models/season_product_location_line.py +++ b/models/season_product_location_line.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import api, fields, models class SeasonProductLocationLine(models.Model): @@ -8,3 +8,21 @@ class SeasonProductLocationLine(models.Model): product_implantation_location_id = fields.Many2one("product.implantation.location") sale_order_line_id = fields.Many2one("sale.order.line") product_season_id = fields.Many2one("product.season") + picked_weight = fields.Float(compute='_compute_picked_kgs', strings="Total KGs Picked") + invoiced_weight = fields.Float(compute='_compute_invoiced_kgs', strings="Total KGs Invoiced") + + @api.depends( + 'sale_order_line_id.move_ids', + 'sale_order_line_id.move_ids.state', + 'sale_order_line_id.move_ids.quantity_done') + def _compute_picked_kgs(self): + for rec in self: + rec.picked_weight = sum([move_id.quantity_done for move_id in rec.sale_order_line_id.move_ids if move_id.state not in ['draft', 'cancel']]) + + @api.depends( + 'sale_order_line_id.invoice_status', + 'sale_order_line_id.qty_invoiced',) + def _compute_invoiced_kgs(self): + for rec in self: + if rec.sale_order_line_id.invoice_status not in ['cancel']: + rec.invoiced_weight += rec.sale_order_line_id.qty_invoiced diff --git a/views/product_season.xml b/views/product_season.xml index e2253f105f9a21b20263aee377bf45bf80cb6f46..909e52273030d6c45abf4e5c102ee176ee2f51c9 100644 --- a/views/product_season.xml +++ b/views/product_season.xml @@ -40,6 +40,8 @@ <tree create="false"> <field name="product_implantation_location_id"/> <field name="sale_order_line_id"/> + <field name="picked_weight"/> + <field name="invoiced_weight"/> </tree> </field> </group> diff --git a/views/sale_order_line.xml b/views/sale_order_line.xml index 2de20380a759a8f30e6ab67a952d82b8e9ce6601..b715d7c3e3c6c7094482f852ba4f5177ebdba956 100644 --- a/views/sale_order_line.xml +++ b/views/sale_order_line.xml @@ -11,10 +11,6 @@ <field name="plantation_id"/> </xpath> - <xpath expr="/form/sheet/notebook/page/field[@name='order_line']/form/group/group/div/field[@name='product_uom_qty']" position="attributes"> - <attribute name="attrs">{'readonly':[('plantation_id', '!=', False)]}</attribute> - </xpath> - <xpath expr="/form/sheet/notebook/page/field[@name='order_line']/form/group/group/field[@name='product_id']" position="attributes"> <attribute name="attrs">{'readonly':[('plantation_id', '!=', False)]}</attribute> </xpath> @@ -25,12 +21,17 @@ <xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_uom_qty']" position="attributes"> <attribute name="attrs">{'readonly':[('plantation_id', '!=', False)]}</attribute> + <attribute name="force_save">True</attribute> </xpath> <xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_id']" position="attributes"> <attribute name="attrs">{'readonly':[('plantation_id', '!=', False)]}</attribute> </xpath> + <xpath expr="/form/sheet/group/group/field[@name='validity_date']" position="attributes"> + <attribute name="required">True</attribute> + </xpath> + </field> </record>