From 5ed80452d1411da83ec74bc9464329964a5d2531 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Thu, 16 Feb 2017 10:34:04 +0100 Subject: [PATCH 1/4] [FIX] account: missing depends when computing total amount of invoice self.type is used inside method but is not present in the dependencies. OPW 706029 close #14187 --- addons/account/models/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 3801b9fc34f..917f17e9950 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -42,7 +42,7 @@ class AccountInvoice(models.Model): _order = "date_invoice desc, number desc, id desc" @api.one - @api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'currency_id', 'company_id', 'date_invoice') + @api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'currency_id', 'company_id', 'date_invoice', 'type') def _compute_amount(self): self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line_ids) self.amount_tax = sum(line.amount for line in self.tax_line_ids) From a2cf865dfe7b83ba610780da4b078c026c5e262e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 16 Feb 2017 14:31:24 +0100 Subject: [PATCH 2/4] [FIX] point_of_sale: use valid sequence on pos.order.line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2 sequences are created when a pos.config is created: - one for pos.order, stored in sequence_id field - one for pos.order.line, link is lost, like dust in the wind ♫ When creating a pos.order.line from a new order, the default value was using the first sequence if found using the code 'pos.order.line' (returning the latest created). The name of the line was always using the same sequence, whatever the config used. In master, the field has been stored at 645df676 but in stable version, the following hack is done: As the sequences are created in the same transaction as the pos.config, the create_date will be the same to the microsecond. The name of the config can not be used as too easily changed (e.g. duplicate) and may not be unique. Done in SQL to avoid ORM cleaning of microseconds, not working with a search. opw-703092 --- addons/point_of_sale/point_of_sale.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 3380208b484..879fc1b388d 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -1529,6 +1529,31 @@ class pos_order_line(osv.osv): res[line.id] = line.order_id.fiscal_position_id.map_tax(line.tax_ids) return res + @api.model + def create(self, values): + if values.get('order_id') and not values.get('name'): + # set name based on the sequence specified on the config + config_id = self.env['pos.order'].browse(values['order_id']).session_id.config_id.id + # HACK: sequence created in the same transaction as the config + # cf TODO master is pos.config create + # remove me saas-15 + self.env.cr.execute(""" + SELECT s.id + FROM ir_sequence s + JOIN pos_config c + ON s.create_date=c.create_date + WHERE c.id = %s + AND s.code = 'pos.order.line' + LIMIT 1 + """, (config_id,)) + sequence = self.env.cr.fetchone() + if sequence: + values['name'] = self.env['ir.sequence'].browse(sequence[0])._next() + if not values.get('name'): + # fallback on any pos.order sequence + values['name'] = self.env['ir.sequence'].next_by_code('pos.order.line') + return super(pos_order_line, self).create(values) + _columns = { 'company_id': fields.many2one('res.company', 'Company', required=True), 'name': fields.char('Line No', required=True, copy=False), @@ -1566,7 +1591,6 @@ class pos_order_line(osv.osv): _defaults = { - 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').next_by_code(cr, uid, 'pos.order.line', context=context), 'qty': lambda *a: 1, 'discount': lambda *a: 0.0, 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, From 40507c4ad9edbbd99e9461b966b3d676c83502a6 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 15 Feb 2017 14:10:33 +0100 Subject: [PATCH 3/4] [FIX] purchase: null stock_moves creation Backport of 1f6ec2b8d65279ca6a5259ee91d098dc4d1a71f2 When the quantity of a purchase order line is manually decreased and if the purchase order line as been generated by more than one procurement. If the new quantity is lower than the quantity of the smallest procurement, it is impossible to validate the picking containg the stock_moves created by the purchase order validation. It is impossible to validate the picking, because it contains stock_moves with 'product_qty' set to 0. Those stock_moves are generated during the validation of a purchase order. To fix this issue, we avoid the creation of stock moves with a 'product_qty' set to 0 which has no sense. opw:708099 --- addons/purchase/purchase.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 89e7e10b812..f7edbb994b2 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -609,15 +609,16 @@ class PurchaseOrderLine(models.Model): diff_quantity = line.product_qty for procurement in line.procurement_ids: procurement_qty = procurement.product_uom._compute_qty_obj(procurement.product_uom, procurement.product_qty, line.product_uom) - tmp = template.copy() - tmp.update({ - 'product_uom_qty': min(procurement_qty, diff_quantity), - 'move_dest_id': procurement.move_dest_id.id, #move destination is same as procurement destination - 'procurement_id': procurement.id, - 'propagate': procurement.rule_id.propagate, - }) - done += moves.create(tmp) - diff_quantity -= min(procurement_qty, diff_quantity) + if float_compare(diff_quantity, 0.0, precision_rounding=line.product_uom.rounding) > 0: + tmp = template.copy() + tmp.update({ + 'product_uom_qty': min(procurement_qty, diff_quantity), + 'move_dest_id': procurement.move_dest_id.id, #move destination is same as procurement destination + 'procurement_id': procurement.id, + 'propagate': procurement.rule_id.propagate, + }) + done += moves.create(tmp) + diff_quantity -= min(procurement_qty, diff_quantity) if float_compare(diff_quantity, 0.0, precision_rounding=line.product_uom.rounding) > 0: template['product_uom_qty'] = diff_quantity done += moves.create(template) From a7531810f39ddc1f59d0e4da4de45ce8e4a44b49 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 17 Feb 2017 11:03:50 +0100 Subject: [PATCH 4/4] [IMP] doc: more explicit section name A section for uncategorised methods. Fixes https://twitter.com/mannequin/status/832360802422312962 --- doc/reference/orm.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/reference/orm.rst b/doc/reference/orm.rst index 202b5ba53dd..f96b927e995 100644 --- a/doc/reference/orm.rst +++ b/doc/reference/orm.rst @@ -671,7 +671,7 @@ Model Reference .. automethod:: fields_get .. automethod:: fields_view_get - .. rubric:: ??? + .. rubric:: Miscellaneous methods .. automethod:: default_get .. automethod:: copy