diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index 45ff78b7caf..f7ffbecc967 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -399,9 +399,9 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { .attr("data-content", qweb.render('reconciliation.line.mv_line.details', {'line': line})); } if (line.already_paid === false && - ((state.balance.amount_currency < 0 || line.partial_reconcile) + (((state.balance.amount_currency < 0 || line.partial_reconcile) && line.amount > 0 && state.st_line.amount > 0 && targetLineAmount < line.amount && partialDebitProps <= 1) || - ((state.balance.amount_currency > 0 || line.partial_reconcile) + ((state.balance.amount_currency > 0 || line.partial_reconcile)) && line.amount < 0 && state.st_line.amount < 0 && targetLineAmount > line.amount && partialCreditProps <= 1)) { var $cell = $line.find(line.amount > 0 ? '.cell_right' : '.cell_left'); var text; diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js index 38a72820223..db8fa1e0104 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -395,6 +395,7 @@ var mv_lines = { '[6,"",0,6]': [ {'account_type': "liquidity", 'amount_currency_str': "", 'currency_id': false, 'date_maturity': "2017-01-23", 'date': "2017-01-23", 'total_amount_str': "$ 376.00", 'partner_id': 7, 'account_name': "Bank", 'name': "BNK1/2017/0002: SUPP.OUT/2017/0002", 'partner_name': "ASUSTeK", 'total_amount_currency_str': "", 'id': 392, 'credit': 376.0, 'journal_id': "Bank", 'amount_str': "$ 376.00", 'debit': 0.0, 'account_code': "101401", 'ref': "BILL/2017/0003", 'already_paid': true}, {'account_type': "liquidity", 'amount_currency_str': "", 'currency_id': false, 'date_maturity': "2017-01-23", 'date': "2017-01-23", 'total_amount_str': "$ 100.00", 'partner_id': 8, 'account_name': "Bank", 'name': "BNK1/2017/0003: CUST.IN/2017/0001", 'partner_name': "Agrolait", 'total_amount_currency_str': "", 'id': 394, 'credit': 0.0, 'journal_id': "Bank", 'amount_str': "$ 100.00", 'debit': 100.0, 'account_code': "101401", 'ref': "", 'already_paid': true}, + {'account_type': "payable", 'amount_currency_str': "", 'currency_id': false, 'date_maturity': "2017-02-28", 'date': "2017-01-01", 'total_amount_str': "$ 10,000.00", 'partner_id': 12, 'account_name': "Account Payable", 'name': "BILL/2017/0001", 'partner_name': "Camptocamp", 'total_amount_currency_str': "", 'id': 114, 'credit': 10000.0, 'journal_id': [2, "Vendor Bills"], 'amount_str': "$ 10,000.00", 'debit': 0.0, 'account_code': "111100", 'ref': "", 'already_paid': false}, {'account_type': "liquidity", 'amount_currency_str': "", 'currency_id': false, 'date_maturity': "2017-01-23", 'date': "2017-01-23", 'total_amount_str': "$ 525.50", 'partner_id': 8, 'account_name': "Bank", 'name': "BNK1/2017/0004: CUST.IN/2017/0002", 'partner_name': "Agrolait", 'total_amount_currency_str': "", 'id': 396, 'credit': 0.0, 'journal_id': "Bank", 'amount_str': "$ 525.50", 'debit': 525.5, 'account_code': "101401", 'ref': "INV/2017/0003", 'already_paid': true}, {'account_type': "receivable", 'amount_currency_str': "", 'currency_id': false, 'date_maturity': "2017-02-07", 'date': "2017-01-08", 'total_amount_str': "$ 650.00", 'partner_id': 8, 'account_name': "101200 Account Receivable", 'name': "INV/2017/0002", 'partner_name': "Agrolait", 'total_amount_currency_str': "", 'id': 109, 'credit': 0.0, 'journal_id': [1, "Customer Invoices"], 'amount_str': "$ 650.00", 'debit': 650.0, 'account_code': "101200", 'ref': "", 'already_paid': false}, {'account_type': "receivable", 'amount_currency_str': "", 'currency_id': false, 'date_maturity': "2017-02-22", 'date': "2017-01-23", 'total_amount_str': "$ 525.00", 'partner_id': 8, 'account_name': "101200 Account Receivable", 'name': "INV/2017/0004", 'partner_name': "Agrolait", 'total_amount_currency_str': "", 'id': 399, 'credit': 0.0, 'journal_id': [1, "Customer Invoices"], 'amount_str': "$ 525.00", 'debit': 525.0, 'account_code': "101200", 'ref': "", 'already_paid': false}, @@ -650,12 +651,12 @@ QUnit.module('account', { clientAction.widgets[1].$('.accounting_view thead td:first').trigger('click'); assert.strictEqual(clientAction.widgets[1].$('.mv_line').length, 5, "should display 5 account move lines"); - assert.strictEqual(clientAction.widgets[1].$('.mv_line .cell_right:not(:empty)').length, 4, "should display only the credit account move lines (hide the debit)"); + assert.strictEqual(clientAction.widgets[1].$('.mv_line .cell_right:not(:empty)').length, 3, "should display only the credit account move lines (hide the debit)"); assert.strictEqual(clientAction.widgets[1].$('.mv_line.already_reconciled').length, 3, "should display 3 already reconciled account move lines"); assert.strictEqual(clientAction.widgets[1].$('.mv_line').text().replace(/[\n\r\s]+/g, ' '), - " 101401 2017-01-23 ASUSTeK: BNK1/2017/0002: SUPP.OUT/2017/0002 : BILL/2017/0003 $ 376.00 101401 2017-01-23 Agrolait: BNK1/2017/0003: CUST.IN/2017/0001 $ 100.00 101401 2017-01-23 Agrolait: BNK1/2017/0004: CUST.IN/2017/0002 : INV/2017/0003 $ 525.50 101200 2017-02-07 Agrolait: INV/2017/0002 $ 650.00 101200 2017-02-22 Agrolait: INV/2017/0004 $ 525.00 ", + " 101401 2017-01-23 ASUSTeK: BNK1/2017/0002: SUPP.OUT/2017/0002 : BILL/2017/0003 $ 376.00 101401 2017-01-23 Agrolait: BNK1/2017/0003: CUST.IN/2017/0001 $ 100.00 111100 2017-02-28 Camptocamp: BILL/2017/0001 $ 10,000.00 101401 2017-01-23 Agrolait: BNK1/2017/0004: CUST.IN/2017/0002 : INV/2017/0003 $ 525.50 101200 2017-02-07 Agrolait: INV/2017/0002 $ 650.00 ", "should display 4 account move lines who contains the account_code, due_date, label and the credit"); - assert.strictEqual(clientAction.widgets[1].$('.mv_line .cell_left:not(:empty)').length, 1, "should display only 1 debit account move lines"); + assert.strictEqual(clientAction.widgets[1].$('.mv_line .cell_left:not(:empty)').length, 2, "should display only 2 debit account move lines"); clientAction.widgets[1].$('.match_controls .fa-chevron-right').trigger('click'); assert.strictEqual(clientAction.widgets[1].$('.mv_line').text().replace(/[\n\r\s]+/g, ' '), " 101200 2017-02-28 Camptocamp: INV/2017/0001 $ 4,610.00 111100 2017-02-28 Camptocamp: BILL/2017/0001 $ 10,000.00 111100 2017-02-28 ASUSTeK: BILL/2017/0002 $ 5,749.99 ", @@ -807,8 +808,13 @@ QUnit.module('account', { [6], [{ partner_id: false, - counterpart_aml_dicts:[], - payment_aml_ids: [392], + counterpart_aml_dicts:[{ + "counterpart_aml_id": 114, + "credit": 0, + "debit": 32.57999999999993, + "name": "BILL/2017/0001" + }], + payment_aml_ids: [], new_aml_dicts: [], }] ], "should call process_bank_statement_line with partial reconcile values"); @@ -837,7 +843,7 @@ QUnit.module('account', { assert.notOk( widget.$('.cell_left .line_info_button').length, "should not display the partial reconciliation alert"); widget.$('.accounting_view thead td:first').trigger('click'); - widget.$('.match .cell_account_code:first').trigger('click'); + widget.$('.match .mv_line[data-line-id=114] .cell_account_code').trigger('click'); assert.equal( widget.$('.accounting_view tbody .cell_left .line_info_button').length, 1, "should display the partial reconciliation alert"); assert.ok( widget.$('button.btn-primary:not(hidden)').length, "should not display the reconcile button"); assert.ok( widget.$('.text-danger:not(hidden)').length, "should display counterpart alert"); diff --git a/addons/hr_payroll/models/hr_payslip.py b/addons/hr_payroll/models/hr_payslip.py index 93ee4d42393..c7d7cb6e407 100644 --- a/addons/hr_payroll/models/hr_payslip.py +++ b/addons/hr_payroll/models/hr_payslip.py @@ -180,9 +180,9 @@ class HrPayslip(models.Model): for interval in day_intervals: holiday = interval[2]['leaves'].holiday_id current_leave_struct = leaves.setdefault(holiday.holiday_status_id, { - 'name': holiday.holiday_status_id.name, + 'name': holiday.holiday_status_id.name or _('Global Leaves'), 'sequence': 5, - 'code': holiday.holiday_status_id.name, + 'code': holiday.holiday_status_id.name or 'GLOBAL', 'number_of_days': 0.0, 'number_of_hours': 0.0, 'contract_id': contract.id, diff --git a/addons/iap/models/iap.py b/addons/iap/models/iap.py index 2f7053b7c74..13431caca7b 100644 --- a/addons/iap/models/iap.py +++ b/addons/iap/models/iap.py @@ -66,7 +66,7 @@ def jsonrpc(url, method='call', params=None): e.data = response['error']['data'] raise e return response.get('result') - except (ValueError, requests.exceptions.ConnectionError, requests.exceptions.MissingSchema) as e: + except (ValueError, requests.exceptions.ConnectionError, requests.exceptions.MissingSchema, requests.exceptions.Timeout, requests.exceptions.HTTPError) as e: raise exceptions.AccessError('The url that this service requested returned an error. Please contact the author the app. The url it tried to contact was ' + url) #---------------------------------------------------------- @@ -78,7 +78,7 @@ class IapTransaction(object): self.credit = None @contextlib.contextmanager -def charge(env, key, account_token, credit, description=None, credit_template=None): +def charge(env, key, account_token, credit, description=None, credit_template=None, dbuuid=False): """ Account charge context manager: takes a hold for ``credit`` amount before executing the body, then captures it if there @@ -102,6 +102,7 @@ def charge(env, key, account_token, credit, description=None, credit_template=No 'credit': credit, 'key': key, 'description': description, + 'dbuuid': dbuuid, } try: transaction_token = jsonrpc(endpoint + '/iap/1/authorize', params=params) diff --git a/addons/l10n_nl/data/account_data.xml b/addons/l10n_nl/data/account_data.xml index 55cccae643d..78531cb730b 100644 --- a/addons/l10n_nl/data/account_data.xml +++ b/addons/l10n_nl/data/account_data.xml @@ -9,6 +9,9 @@ BTW 6% + + BTW 9% + BTW 21% @@ -18,6 +21,9 @@ BTW 6% EU + + BTW 9% EU + BTW 21% EU @@ -27,6 +33,9 @@ BTW 6% Niet EU + + BTW 9% Niet EU + BTW 21% Niet EU diff --git a/addons/l10n_nl/data/account_fiscal_position_tax_template.xml b/addons/l10n_nl/data/account_fiscal_position_tax_template.xml index bb3153bab97..366ec73618f 100644 --- a/addons/l10n_nl/data/account_fiscal_position_tax_template.xml +++ b/addons/l10n_nl/data/account_fiscal_position_tax_template.xml @@ -16,6 +16,11 @@ + + + + + @@ -36,6 +41,11 @@ + + + + + @@ -52,6 +62,11 @@ + + + + + @@ -67,6 +82,11 @@ + + + + + @@ -89,6 +109,11 @@ + + + + + @@ -109,6 +134,11 @@ + + + + + @@ -124,6 +154,11 @@ + + + + + @@ -139,6 +174,11 @@ + + + + + diff --git a/addons/l10n_nl/data/account_tax_template.xml b/addons/l10n_nl/data/account_tax_template.xml index e9b937b98f5..0dfd73d125e 100644 --- a/addons/l10n_nl/data/account_tax_template.xml +++ b/addons/l10n_nl/data/account_tax_template.xml @@ -20,7 +20,7 @@ 10 - Verkopen/omzet laag + Verkopen/omzet laag 6% 6% BTW percent @@ -30,6 +30,19 @@ + + 10 + + Verkopen/omzet laag 9% + 9% BTW + + percent + + + sale + + + 5 @@ -73,7 +86,7 @@ 10 - Verkopen/omzet laag diensten + Verkopen/omzet laag diensten 6% 6% BTW diensten percent @@ -83,6 +96,19 @@ + + 10 + + Verkopen/omzet laag diensten 9% + 9% BTW diensten + + percent + + + sale + + + 6 @@ -113,7 +139,7 @@ 10 - BTW te vorderen laag (inkopen) + BTW te vorderen laag (inkopen) 6% 6% BTW percent @@ -123,10 +149,24 @@ + + 10 + + BTW te vorderen laag (inkopen) 9% + 9% BTW + + percent + + + purchase + + + + 10 - BTW te vorderen laag (inkopen incl. BTW) + BTW te vorderen laag (inkopen incl. BTW) 6% 6% BTW Incl. percent @@ -137,6 +177,20 @@ + + 10 + + BTW te vorderen laag (inkopen incl. BTW) 9% + 9% BTW Incl. + + percent + True + + + purchase + + + 5 @@ -181,7 +235,7 @@ 10 - BTW te vorderen laag (inkopen) diensten + BTW te vorderen laag (inkopen) diensten 6% 6% BTW diensten percent @@ -191,6 +245,19 @@ + + 10 + + BTW te vorderen laag (inkopen) diensten 9% + 9% BTW diensten + + percent + + + purchase + + + 6 @@ -231,7 +298,7 @@ - + 98 BTW te vorderen verlegd (inkopen1) @@ -276,7 +343,7 @@ 21 - Inkopen import binnen EU laag(1) + Inkopen import binnen EU laag(1) 6% Inkopen import binnen EU laag(1) percent @@ -286,10 +353,23 @@ + + + 21 + Inkopen import binnen EU laag(1) 9% + Inkopen import binnen EU laag(1) + + percent + + + none + + + 22 - Inkopen import binnen EU laag(2) + Inkopen import binnen EU laag(2) 6% Inkopen import binnen EU laag(2) percent @@ -299,10 +379,23 @@ + + + 22 + Inkopen import binnen EU laag(2) 9% + Inkopen import binnen EU laag(2) + + percent + + + none + + + 20 - Inkopen import binnen EU laag + Inkopen import binnen EU laag 6% 6% BTW import binnen EU group @@ -311,6 +404,18 @@ + + 20 + + Inkopen import binnen EU laag 9% + 9% BTW import binnen EU + + group + purchase + + + + 21 @@ -418,7 +523,7 @@ 21 - Inkopen import binnen EU laag(1) diensten + Inkopen import binnen EU laag(1) diensten 6% Inkopen import binnen EU laag(1) diensten percent @@ -428,10 +533,23 @@ + + + 21 + Inkopen import binnen EU laag(1) diensten 9% + Inkopen import binnen EU laag(1) diensten + + percent + + + none + + + 22 - Inkopen import binnen EU laag(2) diensten + Inkopen import binnen EU laag(2) diensten 6% Inkopen import binnen EU laag(2) diensten percent @@ -441,10 +559,23 @@ + + + 22 + Inkopen import binnen EU laag(2) diensten 9% + Inkopen import binnen EU laag(2) diensten + + percent + + + none + + + 20 - Inkopen import binnen EU laag diensten + Inkopen import binnen EU laag diensten 6% 6% BTW import binnen EU diensten group @@ -453,6 +584,18 @@ + + 20 + + Inkopen import binnen EU laag diensten 9% + 9% BTW import binnen EU diensten + + group + purchase + + + + 21 @@ -534,7 +677,7 @@ - Inkopen import buiten EU laag(1) + Inkopen import buiten EU laag(1) 6% Inkopen import buiten EU laag(1) percent @@ -545,9 +688,22 @@ + + + Inkopen import buiten EU laag(1) 9% + Inkopen import buiten EU laag(1) + + percent + + + 21 + none + + + - Inkopen import buiten EU laag(2) + Inkopen import buiten EU laag(2) 6% Inkopen import buiten EU laag(2) percent @@ -558,10 +714,23 @@ + + + Inkopen import buiten EU laag(2) 9% + Inkopen import buiten EU laag(2) + + percent + + + 22 + none + + + 20 - Inkopen import buiten EU laag + Inkopen import buiten EU laag 6% BTW import buiten EU laag inkopen group @@ -570,6 +739,18 @@ + + 20 + + Inkopen import buiten EU laag 9% + BTW import buiten EU laag inkopen + + group + purchase + + + + Inkopen import buiten EU hoog(1) @@ -676,7 +857,7 @@ - Inkopen import buiten EU laag(1) diensten + Inkopen import buiten EU laag(1) diensten 6% Inkopen import buiten EU laag(1) diensten percent @@ -687,9 +868,22 @@ + + + Inkopen import buiten EU laag(1) diensten 9% + Inkopen import buiten EU laag(1) diensten + + percent + + + 21 + none + + + - Inkopen import buiten EU laag(2) diensten + Inkopen import buiten EU laag(2) diensten 6% Inkopen import buiten EU laag(2) diensten percent @@ -700,10 +894,23 @@ + + + Inkopen import buiten EU laag(2) diensten 9% + Inkopen import buiten EU laag(2) diensten + + percent + + + 22 + none + + + 20 - Inkopen import buiten EU laag diensten + Inkopen import buiten EU laag diensten 6% BTW import buiten EU laag inkopen diensten group @@ -712,6 +919,18 @@ + + 20 + + Inkopen import buiten EU laag diensten 9% + BTW import buiten EU laag inkopen diensten + + group + purchase + + + + Inkopen import buiten EU hoog(1) diensten diff --git a/addons/l10n_no/data/account_data.xml b/addons/l10n_no/data/account_data.xml index 72f40f19ae7..b0c9d690ce6 100644 --- a/addons/l10n_no/data/account_data.xml +++ b/addons/l10n_no/data/account_data.xml @@ -9,6 +9,9 @@ MVA 10% + + MVA 12% + MVA 15% diff --git a/addons/l10n_no/data/account_tax_data.xml b/addons/l10n_no/data/account_tax_data.xml index 2609ee6f0bc..814f585514e 100644 --- a/addons/l10n_no/data/account_tax_data.xml +++ b/addons/l10n_no/data/account_tax_data.xml @@ -103,7 +103,19 @@ - + + + + + Utgående 12% mva + Utgående 12% mva + 12 + percent + sale + + + + @@ -139,9 +151,20 @@ - + + + + + Inngående 12% mva + Inngående 12% mva + 12 + percent + purchase + + + + - Inngående 0% mva diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 98d1e3392c5..dbd39ceafce 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -382,17 +382,36 @@ class ProductProduct(models.Model): self.check_access_rule("read") result = [] + + # Prefetch the fields used by the `name_get`, so `browse` doesn't fetch other fields + # Use `load=False` to not call `name_get` for the `product_tmpl_id` + self.sudo().read(['name', 'default_code', 'product_tmpl_id', 'attribute_value_ids'], load=False) + + product_template_ids = self.sudo().mapped('product_tmpl_id').ids + + if partner_ids: + supplier_info = self.env['product.supplierinfo'].sudo().search([ + ('product_tmpl_id', 'in', product_template_ids), + ('name', 'in', partner_ids), + ]) + # Prefetch the fields used by the `name_get`, so `browse` doesn't fetch other fields + # Use `load=False` to not call `name_get` for the `product_tmpl_id` and `product_id` + supplier_info.sudo().read(['product_tmpl_id', 'product_id', 'product_name', 'product_code'], load=False) + supplier_info_by_template = {} + for r in supplier_info: + supplier_info_by_template.setdefault(r.product_tmpl_id, []).append(r) for product in self.sudo(): # display only the attributes with multiple possible values on the template - variable_attributes = product.attribute_line_ids.filtered(lambda l: len(l.value_ids) > 1).mapped('attribute_id') + variable_attributes = product.attribute_value_ids.filtered(lambda v: len(v.attribute_id.value_ids) > 1).mapped('attribute_id') variant = product.attribute_value_ids._variant_name(variable_attributes) name = variant and "%s (%s)" % (product.name, variant) or product.name sellers = [] if partner_ids: - sellers = [x for x in product.seller_ids if (x.name.id in partner_ids) and (x.product_id == product)] + product_supplier_info = supplier_info_by_template.get(product.product_tmpl_id, []) + sellers = [x for x in product_supplier_info if x.product_id and x.product_id == product] if not sellers: - sellers = [x for x in product.seller_ids if (x.name.id in partner_ids) and not x.product_id] + sellers = [x for x in product_supplier_info if not x.product_id] if sellers: for s in sellers: seller_variant = s.product_name and ( diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index c4566a7d981..766aadefb37 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -354,6 +354,8 @@ class ProductTemplate(models.Model): @api.multi def name_get(self): + # Prefetch the fields used by the `name_get`, so `browse` doesn't fetch other fields + self.read(['name', 'default_code']) return [(template.id, '%s%s' % (template.default_code and '[%s] ' % template.default_code or '', template.name)) for template in self] diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index 46df20ce9de..851f865384b 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -74,10 +74,10 @@ class PurchaseReport(models.Model): extract(epoch from age(s.date_approve,s.date_order))/(24*60*60)::decimal(16,2) as delay, extract(epoch from age(l.date_planned,s.date_order))/(24*60*60)::decimal(16,2) as delay_pass, count(*) as nbr_lines, - sum(l.price_unit / COALESCE(cr.rate, 1.0) * l.product_qty)::decimal(16,2) as price_total, - avg(100.0 * (l.price_unit / COALESCE(cr.rate,1.0) * l.product_qty) / NULLIF(ip.value_float*l.product_qty/u.factor*u2.factor, 0.0))::decimal(16,2) as negociation, + sum(l.price_unit / COALESCE(NULLIF(cr.rate, 0), 1.0) * l.product_qty)::decimal(16,2) as price_total, + avg(100.0 * (l.price_unit / COALESCE(NULLIF(cr.rate, 0),1.0) * l.product_qty) / NULLIF(ip.value_float*l.product_qty/u.factor*u2.factor, 0.0))::decimal(16,2) as negociation, sum(ip.value_float*l.product_qty/u.factor*u2.factor)::decimal(16,2) as price_standard, - (sum(l.product_qty * l.price_unit / COALESCE(cr.rate, 1.0))/NULLIF(sum(l.product_qty/u.factor*u2.factor),0.0))::decimal(16,2) as price_average, + (sum(l.product_qty * l.price_unit / COALESCE(NULLIF(cr.rate, 0), 1.0))/NULLIF(sum(l.product_qty/u.factor*u2.factor),0.0))::decimal(16,2) as price_average, partner.country_id as country_id, partner.commercial_partner_id as commercial_partner_id, analytic_account.id as account_analytic_id, diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 7c9d0cba786..f501553e8a7 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -263,7 +263,14 @@ class SaleOrderLine(models.Model): @api.onchange('product_uom_qty') def _onchange_product_uom_qty(self): - if self.state == 'sale' and self.product_id.type in ['product', 'consu'] and self.product_uom_qty < self._origin.product_uom_qty: + # When modifying a one2many, _origin doesn't guarantee that its values will be the ones + # in database. Hence, we need to explicitly read them from there. + if self._origin: + product_uom_qty_origin = self._origin.read(["product_uom_qty"])[0]["product_uom_qty"] + else: + product_uom_qty_origin = 0 + + if self.state == 'sale' and self.product_id.type in ['product', 'consu'] and self.product_uom_qty < product_uom_qty_origin: # Do not display this warning if the new quantity is below the delivered # one; the `write` will raise an `UserError` anyway. if self.product_uom_qty < self.qty_delivered: diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index bd600c14452..15118b17096 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -387,7 +387,7 @@ class InventoryLine(models.Model): """ for line in self: if line.product_id.type != 'product': - raise UserError(_("You can only adjust stockable products.")) + raise UserError(_("You can only adjust stockable products.") + '\n\n%s -> %s' % (line.product_id.display_name, line.product_id.type)) def _get_quants(self): return self.env['stock.quant'].search([ diff --git a/addons/stock/report/report_location_barcode.xml b/addons/stock/report/report_location_barcode.xml index 426f7037e28..5e001abda2e 100644 --- a/addons/stock/report/report_location_barcode.xml +++ b/addons/stock/report/report_location_barcode.xml @@ -10,7 +10,7 @@