From 4d1d8d457ebb978840e121b3fcdd3bd302cb7b94 Mon Sep 17 00:00:00 2001 From: Hetashree Chauhan Date: Wed, 23 May 2018 18:07:49 +0530 Subject: [PATCH] [IMP] purchase: create bill button Before this commit the user add to click on vendor bill button that redirect him to an empty list view where he has to click on create. Now, vendor bill show a list view of existing invoice and it exists a new button create bill that directly create a new invoice with missing delivered product. It also order button in order to put primary buttons first in the header. The tour is modify since the stat button is invisible if the PO does not have an invoice linked. Instead it clicks on 'create bill' button. This commit is related to task ID 1835441. --- addons/purchase/models/purchase.py | 16 +++++++--------- addons/purchase/views/purchase_views.xml | 10 ++++++---- .../addons/test_main_flows/static/src/js/tour.js | 6 +----- 3 files changed, 14 insertions(+), 18 deletions(-) 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"),