[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.
This commit is contained in:
Hetashree Chauhan
2018-08-28 15:36:34 +02:00
committed by Arnold Moyaux
parent 19e62fa7c3
commit 4d1d8d457e
3 changed files with 14 additions and 18 deletions
+7 -9
View File
@@ -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)
+6 -4
View File
@@ -132,13 +132,15 @@
<form string="Purchase Order">
<header>
<button name="action_rfq_send" states="draft" string="Send by Email" type="object" context="{'send_rfq':True}" class="oe_highlight"/>
<button name="action_rfq_send" states="sent" string="Re-Send by Email" type="object" context="{'send_rfq':True}"/>
<button name="print_quotation" string="Print RFQ" type="object" states="draft" class="oe_highlight" groups="base.group_user"/>
<button name="print_quotation" string="Print RFQ" type="object" states="sent" groups="base.group_user"/>
<button name="button_confirm" type="object" states="draft" string="Confirm Order" id="draft_confirm"/>
<button name="button_confirm" type="object" states="sent" string="Confirm Order" class="oe_highlight" id="bid_confirm"/>
<button name="button_approve" type="object" states='to approve' string="Approve Order" class="oe_highlight" groups="purchase.group_purchase_manager"/>
<button name="action_view_invoice" string="Create Bill" type="object" class="oe_highlight" context="{'create_bill':True}" attrs="{'invisible': ['|', ('state', 'not in', ('purchase')), ('invoice_status', 'in', ('no', 'invoiced'))]}"/>
<button name="action_rfq_send" states="sent" string="Re-Send by Email" type="object" context="{'send_rfq':True}"/>
<button name="print_quotation" string="Print RFQ" type="object" states="sent" groups="base.group_user"/>
<button name="button_confirm" type="object" states="draft" string="Confirm Order" id="draft_confirm"/>
<button name="action_rfq_send" states="purchase" string="Send PO by Email" type="object" context="{'send_rfq':False}"/>
<button name="action_view_invoice" string="Create Bill" type="object" context="{'create_bill':True}" attrs="{'invisible': ['|', '|', ('state', 'not in', ('purchase')), ('invoice_status', 'not in', ('no', 'invoiced')), ('order_line', '=', [])]}"/>
<button name="button_draft" states="cancel" string="Set to Draft" type="object" />
<button name="button_cancel" states="draft,to approve,sent,purchase" string="Cancel" type="object" />
<button name="button_done" type="object" string="Lock" states="purchase"/>
@@ -149,7 +151,7 @@
<div class="oe_button_box" name="button_box">
<button type="object" name="action_view_invoice"
class="oe_stat_button"
icon="fa-pencil-square-o" attrs="{'invisible':[('state', 'in', ('draft','sent','to approve')),('invoice_ids','=',[])]}">
icon="fa-pencil-square-o" attrs="{'invisible':['|', ('invoice_count', '=', 0), ('state', 'in', ('draft','sent','to approve'))]}">
<field name="invoice_count" widget="statinfo" string="Vendor Bills"/>
<field name='invoice_ids' invisible="1"/>
</button>
@@ -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"),