diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 61202d30e7d..8e8ae8c77b6 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -368,7 +368,7 @@ class PurchaseOrder(models.Model): ''' action = self.env.ref('account.action_vendor_bill_template') result = action.read()[0] - + create_bill = self.env.context.get('create_bill', False) # override the context to get rid of the default filtering result['context'] = { 'type': 'in_invoice', @@ -378,16 +378,14 @@ class PurchaseOrder(models.Model): 'company_id': self.company_id.id } # choose the view_mode accordingly - if len(self.invoice_ids) != 1: + if len(self.invoice_ids) > 1 and not create_bill: result['domain'] = "[('id', 'in', " + str(self.invoice_ids.ids) + ")]" - elif len(self.invoice_ids) == 1: + else: res = self.env.ref('account.invoice_supplier_form', False) result['views'] = [(res and res.id or False, 'form')] - result['res_id'] = self.invoice_ids.id - - # complete the help tooltip - new_help = self.env['account.invoice'].complete_empty_list_help() - result['help'] = result.get('help', '') + new_help + # Do not set an invoice_id if we want to create a new bill. + if not create_bill: + result['res_id'] = self.invoice_ids.id or False return result @api.multi @@ -429,7 +427,7 @@ class PurchaseOrderLine(models.Model): # Replace by invoiced Qty qty_invoiced = fields.Float(compute='_compute_qty_invoiced', string="Billed Qty", digits=dp.get_precision('Product Unit of Measure'), store=True) - qty_received = fields.Float(string="Received Qty", digits=dp.get_precision('Product Unit of Measure')) + qty_received = fields.Float(string="Received Qty", digits=dp.get_precision('Product Unit of Measure'), copy=False) partner_id = fields.Many2one('res.partner', related='order_id.partner_id', string='Partner', readonly=True, store=True) currency_id = fields.Many2one(related='order_id.currency_id', store=True, string='Currency', readonly=True) diff --git a/addons/purchase/views/purchase_views.xml b/addons/purchase/views/purchase_views.xml index 425fd472087..5a55d19a3d4 100644 --- a/addons/purchase/views/purchase_views.xml +++ b/addons/purchase/views/purchase_views.xml @@ -132,13 +132,15 @@
diff --git a/odoo/addons/test_main_flows/static/src/js/tour.js b/odoo/addons/test_main_flows/static/src/js/tour.js index bc0bca503e0..e0f209c2232 100644 --- a/odoo/addons/test_main_flows/static/src/js/tour.js +++ b/odoo/addons/test_main_flows/static/src/js/tour.js @@ -480,13 +480,9 @@ tour.register('main_flow_tour', { content: _t('go back to the purchase order'), position: 'bottom', }, { - trigger: ".oe_button_box .oe_stat_button:has(div[name=invoice_count])", + trigger: ".o_statusbar_buttons > button:enabled:contains('Create Bill')", content: _t('go to Vendor Bills'), position: 'bottom', -}, { - trigger: ".o_list_button_add", - content: _t("Let's create a new vendor bill"), - position: "right", }, { trigger: ".o_statusbar_buttons > button:enabled:contains('Validate')", content: _t("Try to send it to email"),