From 9b47764bbde582260c57632b77dbfd2daed0e4ff Mon Sep 17 00:00:00 2001 From: Kristen Marie Kulha Date: Fri, 14 Sep 2018 11:05:35 -0700 Subject: [PATCH 1/9] Added computed field `has_catch_weight` to `stock.picking` model in `product_catch_weight` module. Additionally, added filter and group by for `has_catch_weight` to stock.picking search view. --- .../models/account_invoice.py | 6 ++++- product_catch_weight/models/stock.py | 12 ++++++++- product_catch_weight/views/stock_views.xml | 26 ++++++++++++------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/product_catch_weight/models/account_invoice.py b/product_catch_weight/models/account_invoice.py index ee8c9f92..c6b3db66 100644 --- a/product_catch_weight/models/account_invoice.py +++ b/product_catch_weight/models/account_invoice.py @@ -27,8 +27,12 @@ class AccountInvoiceLine(models.Model): move_lines = self.purchase_line_id.mapped('move_ids.move_line_ids') for move_line in move_lines: qty_done = move_line.qty_done + current_qty_done = qty_done + qty_done_total r = move_line.lot_id.catch_weight_ratio - ratio = ((ratio * qty_done_total) + (qty_done * r)) / (qty_done + qty_done_total) + if current_qty_done == 0: + ratio = 0 + else: + ratio = ((ratio * qty_done_total) + (qty_done * r)) / current_qty_done qty_done_total += qty_done catch_weight += move_line.lot_id.catch_weight price = price * ratio diff --git a/product_catch_weight/models/stock.py b/product_catch_weight/models/stock.py index 1ad5d3b6..c5cc9363 100644 --- a/product_catch_weight/models/stock.py +++ b/product_catch_weight/models/stock.py @@ -8,7 +8,6 @@ class StockProductionLot(models.Model): catch_weight = fields.Float(string='Catch Weight', digits=(10, 4)) catch_weight_uom_id = fields.Many2one('product.uom', related='product_id.catch_weight_uom_id') - @api.depends('catch_weight') def _compute_catch_weight_ratio(self): for lot in self: @@ -44,3 +43,14 @@ class StockMoveLine(models.Model): catch_weight_uom_id = fields.Many2one('product.uom', string='Catch Weight UOM') lot_catch_weight = fields.Float(related='lot_id.catch_weight') lot_catch_weight_uom_id = fields.Many2one('product.uom', related='product_id.catch_weight_uom_id') + + +class StockPicking(models.Model): + _inherit = 'stock.picking' + + has_catch_weight = fields.Boolean(string="Has Catch Weight", compute='_compute_has_catch_weight', store=True) + + @api.depends('move_lines.product_catch_weight_uom_id') + def _compute_has_catch_weight(self): + for picking in self: + picking.has_catch_weight = any(picking.mapped('move_lines.product_catch_weight_uom_id')) diff --git a/product_catch_weight/views/stock_views.xml b/product_catch_weight/views/stock_views.xml index 40e2d9dd..3ce9015d 100644 --- a/product_catch_weight/views/stock_views.xml +++ b/product_catch_weight/views/stock_views.xml @@ -13,16 +13,6 @@ - - - - - - - - - - stock.move.operations.form.inherit stock.move @@ -36,6 +26,7 @@ + stock.move.line.operations.tree.inherit stock.move.line @@ -49,6 +40,7 @@ + product.template.common.form.inherit product.template @@ -59,4 +51,18 @@ + + + stock.view.picking.internal.search.inherit + stock.picking + + + + + + + + + + \ No newline at end of file From 2e3c2e57090a34ffaa2fcf166917db14c330b893 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Thu, 20 Sep 2018 14:46:50 -0700 Subject: [PATCH 2/9] Initial commit of `sale_line_change` for 11.0 Additionally, improve UI on `rma` and `rma_sale` by not allowing creating or deleting lines in wizard views. --- rma/wizard/rma_lines_views.xml | 2 +- rma_sale/wizard/rma_lines_views.xml | 2 +- sale_line_change/__init__.py | 1 + sale_line_change/__manifest__.py | 24 ++++++ sale_line_change/views/sale_views.xml | 19 +++++ sale_line_change/wizard/__init__.py | 1 + sale_line_change/wizard/sale_line_change.py | 79 +++++++++++++++++++ .../wizard/sale_line_change_views.xml | 40 ++++++++++ 8 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 sale_line_change/__init__.py create mode 100644 sale_line_change/__manifest__.py create mode 100644 sale_line_change/views/sale_views.xml create mode 100644 sale_line_change/wizard/__init__.py create mode 100644 sale_line_change/wizard/sale_line_change.py create mode 100644 sale_line_change/wizard/sale_line_change_views.xml diff --git a/rma/wizard/rma_lines_views.xml b/rma/wizard/rma_lines_views.xml index 9515fd03..934c8f71 100644 --- a/rma/wizard/rma_lines_views.xml +++ b/rma/wizard/rma_lines_views.xml @@ -7,7 +7,7 @@
- + diff --git a/rma_sale/wizard/rma_lines_views.xml b/rma_sale/wizard/rma_lines_views.xml index e6486124..dd7a8e03 100644 --- a/rma_sale/wizard/rma_lines_views.xml +++ b/rma_sale/wizard/rma_lines_views.xml @@ -7,7 +7,7 @@ - + diff --git a/sale_line_change/__init__.py b/sale_line_change/__init__.py new file mode 100644 index 00000000..40272379 --- /dev/null +++ b/sale_line_change/__init__.py @@ -0,0 +1 @@ +from . import wizard diff --git a/sale_line_change/__manifest__.py b/sale_line_change/__manifest__.py new file mode 100644 index 00000000..3e58d8d9 --- /dev/null +++ b/sale_line_change/__manifest__.py @@ -0,0 +1,24 @@ +{ + 'name': 'Sale Line Change', + 'summary': 'Change Confirmed Sale Lines Routes or Warehouses.', + 'version': '11.0.1.0.0', + 'author': "Hibou Corp.", + 'category': 'Sale', + 'license': 'AGPL-3', + 'complexity': 'expert', + 'images': [], + 'website': "https://hibou.io", + 'description': """ +""", + 'depends': [ + 'sale_sourced_by_line', + 'sale_stock', + ], + 'demo': [], + 'data': [ + 'wizard/sale_line_change_views.xml', + 'views/sale_views.xml', + ], + 'auto_install': False, + 'installable': True, +} diff --git a/sale_line_change/views/sale_views.xml b/sale_line_change/views/sale_views.xml new file mode 100644 index 00000000..829d4f75 --- /dev/null +++ b/sale_line_change/views/sale_views.xml @@ -0,0 +1,19 @@ + + + + sale.order.form.inherit + sale.order + + + +