From dcfbae05ddd54b139fcb468dc189223672bc52f1 Mon Sep 17 00:00:00 2001 From: "joseluiszanotti@gmail.com@gitlab.e-mips.com.ar" <joseluiszanotti@gmail.com> Date: Wed, 4 Mar 2020 10:51:35 -0300 Subject: [PATCH 1/8] partial --- models/product_product.py | 18 +++++++++++++++++- views/stock_location.xml | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/models/product_product.py b/models/product_product.py index 86f4a56..f13d515 100644 --- a/models/product_product.py +++ b/models/product_product.py @@ -1,6 +1,6 @@ from datetime import datetime -from odoo import fields, models +from odoo import api, fields, models class ProductImplantationLocation(models.Model): @@ -11,3 +11,19 @@ class ProductImplantationLocation(models.Model): implantation_year = fields.Selection( [(num, str(num)) for num in range(2015, 2050)], string="Year", default=datetime.now().strftime("%Y") ) + campaign_id = fields.Many2one("product.season", required=True, ondelete="cascade") + + @api.onchange('implantation_year') + def onchange_implantation_year(self): + campaigns = [] + campaign_ids = self.env['product.season'].search([ + '|', '&', + ('starting_date', '>=', str(self.implantation_year) + '-01-01'), + ('starting_date', '<=', str(self.implantation_year) + '-12-31'), + '&', + ('ending_date', '>=', str(self.implantation_year) + '-01-01'), + ('ending_date', '<=', str(self.implantation_year) + '-12-31'), + ]) + for rec in campaign_ids: + campaigns.append(rec.id) + return {'domain': {'campaign_id': [('id', 'in', campaigns)]}} diff --git a/views/stock_location.xml b/views/stock_location.xml index 1321d49..173ac6c 100644 --- a/views/stock_location.xml +++ b/views/stock_location.xml @@ -12,6 +12,29 @@ </field> </record> + + <record model="ir.ui.view" id="product_implantation_location_form"> + <field name="name">Product Implantation Location Form</field> + <field name="model">product.implantation.location</field> + <field name="arch" type="xml"> + <form string="Season"> + <sheet> + <group> + <group> + <field name="product_id"/> + <field name="implantation_year"/> + </group> + <group> + <field name="campaign_id"/> + </group> + </group> + </sheet> + </form> + + </field> + </record> + + <record model="ir.ui.view" id="view_stock_location_form"> <field name="name">Stock Location</field> <field name="model">stock.location</field> -- GitLab From c03086b3f427c397f766d5bb2e51e9712370f0ba Mon Sep 17 00:00:00 2001 From: "joseluiszanotti@gmail.com@gitlab.e-mips.com.ar" <joseluiszanotti@gmail.com> Date: Thu, 5 Mar 2020 18:46:31 -0300 Subject: [PATCH 2/8] small fixes --- i18n/es_AR.po | 30 +++++++++++++++++++++++------- views/menuitems.xml | 4 ++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/i18n/es_AR.po b/i18n/es_AR.po index 9480dbb..b11740e 100644 --- a/i18n/es_AR.po +++ b/i18n/es_AR.po @@ -206,6 +206,21 @@ msgstr "Ãrea" msgid "Area value must be greater than or equal to zero" msgstr "El valor de Ãrea debe ser mayor o igual a 0" +#. module: citrux_stock +#: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__campaign_id +msgid "Campaign" +msgstr "Campaña" + +#. module: citrux_stock +#: model:ir.model,name:citrux_stock.model_product_season +msgid "Campañas" +msgstr "" + +#. module: citrux_stock +#: model:ir.ui.menu,name:citrux_stock.fruit_production_clients +msgid "Clients" +msgstr "Clientes" + #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__create_uid #: model:ir.model.fields,field_description:citrux_stock.field_product_season__create_uid @@ -312,6 +327,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_sale_order_line__plantation_id +msgid "Plantation" +msgstr "Plantación" + #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_stock_location__plants msgid "Plants" @@ -323,11 +343,6 @@ msgstr "Plantas" msgid "Plants value must be greater than or equal to zero" msgstr "El valor de Plantas debe ser mayor o igual a 0" -#. module: citrux_stock -#: model:ir.ui.menu,name:citrux_stock.fruit_production_producer -msgid "Producer" -msgstr "Productores" - #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__product_id msgid "Product" @@ -341,7 +356,6 @@ msgid "Production" msgstr "Rendimiento" #. module: citrux_stock -#: model:ir.actions.act_window,name:citrux_stock.season_action #: model:ir.ui.menu,name:citrux_stock.production_unit_action msgid "Production Unit" msgstr "Unidad Productiva" @@ -357,12 +371,14 @@ msgid "Relation between stock.location and product.product" msgstr "Relación entre stock.location y product.product" #. module: citrux_stock +#: model:ir.model,name:citrux_stock.model_sale_order_line +msgid "Sales Order Line" +msgstr "LÃnea de pedido de venta #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location__product_season_id msgid "Season" msgstr "Temporada" #. module: citrux_stock -#: model:ir.model,name:citrux_stock.model_product_season #: model:ir.ui.menu,name:citrux_stock.fruit_production_seasons #: model_terms:ir.ui.view,arch_db:citrux_stock.view_product_season msgid "Seasons" diff --git a/views/menuitems.xml b/views/menuitems.xml index fdb4bbc..cc8e994 100644 --- a/views/menuitems.xml +++ b/views/menuitems.xml @@ -29,8 +29,8 @@ action="stock.action_location_form" sequence="3"/> - <menuitem id="fruit_production_producer" - name="Producer" + <menuitem id="fruit_production_clients" + name="Clients" parent="fruit_production_menu_root" action="base.action_partner_form" sequence="5"/> -- GitLab From 0427af5656bfeb5a53756efa06cda2b041f8746c Mon Sep 17 00:00:00 2001 From: "joseluiszanotti@gmail.com@gitlab.e-mips.com.ar" <joseluiszanotti@gmail.com> Date: Tue, 31 Mar 2020 11:12:50 -0300 Subject: [PATCH 3/8] CIT11 + CIT12 --- i18n/es_AR.po | 74 ++++++++++++++++++++++++-- models/__init__.py | 3 ++ models/account_invoice.py | 16 ++++++ models/product_product.py | 1 + models/product_template.py | 11 ++++ models/sale_order_line.py | 2 +- models/season_product_location_line.py | 2 + models/stock_picking.py | 16 ++++++ views/product_season.xml | 2 + views/sale_order_line.xml | 5 +- 10 files changed, 122 insertions(+), 10 deletions(-) create mode 100644 models/account_invoice.py create mode 100644 models/product_template.py create mode 100644 models/stock_picking.py diff --git a/i18n/es_AR.po b/i18n/es_AR.po index a1e1132..be71fcf 100644 --- a/i18n/es_AR.po +++ b/i18n/es_AR.po @@ -307,7 +307,6 @@ msgid "Area value must be greater than or equal to zero" msgstr "El valor de Ãrea debe ser mayor o igual a 0" #. module: citrux_stock -#: model:ir.ui.menu,name:citrux_stock.fruit_production_clients #: model:ir.ui.menu,name:citrux_stock.fruit_production_client msgid "Clients" msgstr "Clientes" @@ -315,6 +314,7 @@ msgstr "Clientes" #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__create_uid #: model:ir.model.fields,field_description:citrux_stock.field_product_season__create_uid +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__create_uid #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location__create_uid msgid "Created by" msgstr "Creado por" @@ -322,6 +322,7 @@ msgstr "Creado por" #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__create_date #: model:ir.model.fields,field_description:citrux_stock.field_product_season__create_date +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__create_date #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location__create_date msgid "Created on" msgstr "Creado el" @@ -329,6 +330,7 @@ msgstr "Creado el" #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__display_name #: model:ir.model.fields,field_description:citrux_stock.field_product_season__display_name +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__display_name #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location__display_name msgid "Display Name" msgstr "Nombre mostrado" @@ -351,6 +353,7 @@ msgstr "Producción de Fruta" #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__id #: model:ir.model.fields,field_description:citrux_stock.field_product_season__id +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__id #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location__id msgid "ID" msgstr "ID" @@ -360,9 +363,20 @@ 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 +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line____last_update #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location____last_update msgid "Last Modified on" msgstr "Última modificación en" @@ -370,6 +384,7 @@ msgstr "Última modificación en" #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__write_uid #: model:ir.model.fields,field_description:citrux_stock.field_product_season__write_uid +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__write_uid #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location__write_uid msgid "Last Updated by" msgstr "Última actualización por" @@ -377,6 +392,7 @@ msgstr "Última actualización por" #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__write_date #: model:ir.model.fields,field_description:citrux_stock.field_product_season__write_date +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__write_date #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location__write_date msgid "Last Updated on" msgstr "Última actualización el" @@ -418,6 +434,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" @@ -440,11 +461,31 @@ msgstr "El valor de Plantas debe ser mayor o igual a 0" msgid "Product" msgstr "Producto" +#. module: citrux_stock +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__product_implantation_location_id +msgid "Product Implantation Location" +msgstr "Ubicación y Producto" + #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_product_implantation_location__location_id msgid "Product Location" msgstr "Ubicación del Producto" +#. module: citrux_stock +#: model:ir.model,name:citrux_stock.model_season_product_location_line +msgid "Product Location Lines of Seasons" +msgstr "Ubicación del Producto en las LÃneas de Facturación" + +#. module: citrux_stock +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__product_season_id +msgid "Product Season" +msgstr "Campaña del Producto" + +#. module: citrux_stock +#: model:ir.model,name:citrux_stock.model_product_template +msgid "Product Template" +msgstr "Plantilla de producto" + #. module: citrux_stock #: model:ir.model.fields,field_description:citrux_stock.field_stock_location__production_ids #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location__production @@ -457,6 +498,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" @@ -472,6 +518,11 @@ msgstr "Relación entre stock.location y product.product" msgid "Sale Order" msgstr "Pedido de venta" +#. module: citrux_stock +#: model:ir.model.fields,field_description:citrux_stock.field_season_product_location_line__sale_order_line_id +msgid "Sale Order Line" +msgstr "Pedido de Venta" + #. module: citrux_stock #: model:ir.model,name:citrux_stock.model_sale_order_line msgid "Sales Order Line" @@ -482,19 +533,22 @@ msgstr "LÃnea de pedido de venta" #: model:ir.model.fields,field_description:citrux_stock.field_stock_production_location__product_season_id #: model_terms:ir.ui.view,arch_db:citrux_stock.view_product_season_form msgid "Season" -msgstr "Temporada" msgstr "Campaña" +#. module: citrux_stock +#: model:ir.model.fields,field_description:citrux_stock.field_product_season__season_line_ids +msgid "Season Lines" +msgstr "Campañas" + #. module: citrux_stock #: model:ir.model,name:citrux_stock.model_product_season #: model:ir.ui.menu,name:citrux_stock.fruit_production_seasons #: model_terms:ir.ui.view,arch_db:citrux_stock.view_product_season msgid "Seasons" -msgstr "Temporadas" msgstr "Campañas" #. module: citrux_stock -#: code:addons/citrux_stock/models/product_season.py:16 +#: code:addons/citrux_stock/models/product_season.py:17 #, python-format msgid "Sorry, End Date Must be greater Than Start Date" msgstr "Lo siento, la Fecha de Finalización debe ser posterios a la Fecha de Inicio..." @@ -509,11 +563,21 @@ msgstr "Fecha de Inicio" msgid "Stock Location" msgstr "Ubicación de existencias" +#. module: citrux_stock +#: model:ir.model,name:citrux_stock.model_stock_move +msgid "Stock Move" +msgstr "Movimiento de existencias" + #. module: citrux_stock #: model:ir.model,name:citrux_stock.model_stock_production_location msgid "Stock Production Location" msgstr "Rendimiento de la Ubicación" +#. module: citrux_stock +#: model:ir.model,name:citrux_stock.model_stock_picking +msgid "Transfer" +msgstr "Transferir" + #. module: citrux_stock #: model:ir.ui.menu,name:citrux_stock.types msgid "Types" @@ -537,7 +601,7 @@ msgid "Year" msgstr "Año" #. module: citrux_stock -#: code:addons/citrux_stock/models/sale_order_line.py:22 +#: code:addons/citrux_stock/models/sale_order_line.py:30 #, python-format msgid "You cannot use Plantations from Different Locations." msgstr "No puedes usar Plantaciones de Diferentes Ubicaciones." diff --git a/models/__init__.py b/models/__init__.py index f707943..8535385 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,9 +1,12 @@ from . import ( + account_invoice, product_product, product_season, + product_template, sale_order_line, season_product_location_line, stock_location, stock_move, + stock_picking, stock_warehouse ) diff --git a/models/account_invoice.py b/models/account_invoice.py new file mode 100644 index 0000000..28d38ff --- /dev/null +++ b/models/account_invoice.py @@ -0,0 +1,16 @@ +from odoo import api, models + + +class AccountInvoice(models.Model): + _inherit = "account.invoice" + + @api.multi + def invoice_validate(self): + res = super(AccountInvoice, self).invoice_validate() + for invoice_line in self.invoice_line_ids: + season_line = self.env["season.product.location.line"].search([('sale_order_line_id', '=', invoice_line.sale_line_ids.id)]) + invoiced_weight = season_line.invoiced_weight + invoice_line.quantity + season_line.write({ + 'invoiced_weight': invoiced_weight, + }) + return res diff --git a/models/product_product.py b/models/product_product.py index ac77583..2a3349d 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 0000000..994a786 --- /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 6a29b35..7924dca 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) diff --git a/models/season_product_location_line.py b/models/season_product_location_line.py index bc94daa..94c2e4c 100644 --- a/models/season_product_location_line.py +++ b/models/season_product_location_line.py @@ -8,3 +8,5 @@ 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(strings="Total KGs Picked") + invoiced_weight = fields.Float(strings="Total KGs Invoiced") diff --git a/models/stock_picking.py b/models/stock_picking.py new file mode 100644 index 0000000..344943a --- /dev/null +++ b/models/stock_picking.py @@ -0,0 +1,16 @@ +from odoo import api, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + @api.multi + def action_done(self): + res = super(StockPicking, self).action_done() + for move_line in self.move_lines: + season_line = self.env["season.product.location.line"].search([('sale_order_line_id', '=', move_line.sale_line_id.id)]) + picked_weight = season_line.picked_weight + move_line.quantity_done + season_line.write({ + 'picked_weight': picked_weight, + }) + return res diff --git a/views/product_season.xml b/views/product_season.xml index e2253f1..909e522 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 2de2038..0f7045e 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,6 +21,7 @@ <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"> -- GitLab From 0ff22ebc5d78573d2b6c14eda946c6309858e60b Mon Sep 17 00:00:00 2001 From: "joseluiszanotti@gmail.com@gitlab.e-mips.com.ar" <joseluiszanotti@gmail.com> Date: Wed, 1 Apr 2020 15:46:20 -0300 Subject: [PATCH 4/8] cit13 done --- models/sale_order_line.py | 2 +- views/sale_order_line.xml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/models/sale_order_line.py b/models/sale_order_line.py index 7924dca..b1a72ea 100644 --- a/models/sale_order_line.py +++ b/models/sale_order_line.py @@ -37,7 +37,7 @@ 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', '<=', rec.validity_date), ('ending_date', '>=', rec.validity_date)]) season.write({ 'season_line_ids': [(0, 0, { 'product_implantation_location_id': rec.plantation_id.id, diff --git a/views/sale_order_line.xml b/views/sale_order_line.xml index 0f7045e..b715d7c 100644 --- a/views/sale_order_line.xml +++ b/views/sale_order_line.xml @@ -28,6 +28,10 @@ <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> -- GitLab From f57e2812e034c53a935b3c71005de5acce6c422b Mon Sep 17 00:00:00 2001 From: "joseluiszanotti@gmail.com@gitlab.e-mips.com.ar" <joseluiszanotti@gmail.com> Date: Wed, 8 Apr 2020 16:38:50 -0300 Subject: [PATCH 5/8] before rebase --- models/__init__.py | 2 -- models/account_invoice.py | 16 ---------------- models/sale_order_line.py | 7 +++++-- models/season_product_location_line.py | 15 ++++++++++++--- models/stock_picking.py | 16 ---------------- views/stock_location.xml | 23 ----------------------- 6 files changed, 17 insertions(+), 62 deletions(-) delete mode 100644 models/account_invoice.py delete mode 100644 models/stock_picking.py diff --git a/models/__init__.py b/models/__init__.py index 8535385..2dfa231 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,5 +1,4 @@ from . import ( - account_invoice, product_product, product_season, product_template, @@ -7,6 +6,5 @@ from . import ( season_product_location_line, stock_location, stock_move, - stock_picking, stock_warehouse ) diff --git a/models/account_invoice.py b/models/account_invoice.py deleted file mode 100644 index 28d38ff..0000000 --- a/models/account_invoice.py +++ /dev/null @@ -1,16 +0,0 @@ -from odoo import api, models - - -class AccountInvoice(models.Model): - _inherit = "account.invoice" - - @api.multi - def invoice_validate(self): - res = super(AccountInvoice, self).invoice_validate() - for invoice_line in self.invoice_line_ids: - season_line = self.env["season.product.location.line"].search([('sale_order_line_id', '=', invoice_line.sale_line_ids.id)]) - invoiced_weight = season_line.invoiced_weight + invoice_line.quantity - season_line.write({ - 'invoiced_weight': invoiced_weight, - }) - return res diff --git a/models/sale_order_line.py b/models/sale_order_line.py index b1a72ea..4b408af 100644 --- a/models/sale_order_line.py +++ b/models/sale_order_line.py @@ -20,7 +20,6 @@ class SaleOrderLine(models.Model): } return res - class SaleOrder(models.Model): _inherit = "sale.order" @@ -37,7 +36,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.validity_date), ('ending_date', '>=', rec.validity_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 94c2e4c..b56a9d8 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,5 +8,14 @@ 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(strings="Total KGs Picked") - invoiced_weight = fields.Float(strings="Total KGs Invoiced") + picked_weight = fields.Float(compute='_compute_picked_kgs', strings="Total KGs Picked") + invoiced_weight = fields.Float(compute='_compute_invoiced_kgs', strings="Total KGs Invoiced") + + 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']]) + + 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/models/stock_picking.py b/models/stock_picking.py deleted file mode 100644 index 344943a..0000000 --- a/models/stock_picking.py +++ /dev/null @@ -1,16 +0,0 @@ -from odoo import api, models - - -class StockPicking(models.Model): - _inherit = "stock.picking" - - @api.multi - def action_done(self): - res = super(StockPicking, self).action_done() - for move_line in self.move_lines: - season_line = self.env["season.product.location.line"].search([('sale_order_line_id', '=', move_line.sale_line_id.id)]) - picked_weight = season_line.picked_weight + move_line.quantity_done - season_line.write({ - 'picked_weight': picked_weight, - }) - return res diff --git a/views/stock_location.xml b/views/stock_location.xml index fdd11e5..b71c57e 100644 --- a/views/stock_location.xml +++ b/views/stock_location.xml @@ -13,29 +13,6 @@ </field> </record> - - <record model="ir.ui.view" id="product_implantation_location_form"> - <field name="name">Product Implantation Location Form</field> - <field name="model">product.implantation.location</field> - <field name="arch" type="xml"> - <form string="Season"> - <sheet> - <group> - <group> - <field name="product_id"/> - <field name="implantation_year"/> - </group> - <group> - <field name="campaign_id"/> - </group> - </group> - </sheet> - </form> - - </field> - </record> - - <record model="ir.ui.view" id="view_stock_location_form"> <field name="name">Stock Location</field> <field name="model">stock.location</field> -- GitLab From 2f5fa71492f14cbf67e4183d055fd3b3c1b7845b Mon Sep 17 00:00:00 2001 From: "joseluiszanotti@gmail.com@gitlab.e-mips.com.ar" <joseluiszanotti@gmail.com> Date: Wed, 8 Apr 2020 16:40:33 -0300 Subject: [PATCH 6/8] before rebase --- models/sale_order_line.py | 1 + models/season_product_location_line.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/models/sale_order_line.py b/models/sale_order_line.py index 4b408af..7e48e4c 100644 --- a/models/sale_order_line.py +++ b/models/sale_order_line.py @@ -20,6 +20,7 @@ class SaleOrderLine(models.Model): } return res + class SaleOrder(models.Model): _inherit = "sale.order" diff --git a/models/season_product_location_line.py b/models/season_product_location_line.py index b56a9d8..fa850da 100644 --- a/models/season_product_location_line.py +++ b/models/season_product_location_line.py @@ -1,4 +1,4 @@ -from odoo import api, fields, models +from odoo import fields, models class SeasonProductLocationLine(models.Model): -- GitLab From 29002b7c7e9291de08c8ba3155e3945420c2a67d Mon Sep 17 00:00:00 2001 From: "joseluiszanotti@gmail.com@gitlab.e-mips.com.ar" <joseluiszanotti@gmail.com> Date: Wed, 8 Apr 2020 17:31:22 -0300 Subject: [PATCH 7/8] depends added --- models/season_product_location_line.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/season_product_location_line.py b/models/season_product_location_line.py index fa850da..3cea863 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): @@ -10,11 +10,13 @@ class SeasonProductLocationLine(models.Model): 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') 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') def _compute_invoiced_kgs(self): for rec in self: if rec.sale_order_line_id.invoice_status not in ['cancel']: -- GitLab From 0c808574d65370b2616ea96a3514b4c898b9bf1f Mon Sep 17 00:00:00 2001 From: "joseluiszanotti@gmail.com@gitlab.e-mips.com.ar" <joseluiszanotti@gmail.com> Date: Wed, 8 Apr 2020 17:44:22 -0300 Subject: [PATCH 8/8] fix --- models/season_product_location_line.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/models/season_product_location_line.py b/models/season_product_location_line.py index 3cea863..72269c9 100644 --- a/models/season_product_location_line.py +++ b/models/season_product_location_line.py @@ -10,13 +10,18 @@ class SeasonProductLocationLine(models.Model): 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') + + @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') + @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']: -- GitLab