[IMP] sale: change some code of functions & change name of field

bzr revid: cha@tinyerp.com-20120911112133-55m46wi003k28ikn
This commit is contained in:
Ajay Chauhan (OpenERP) 2012-09-11 16:51:33 +05:30
parent cbe44438b2
commit 73dc43adc6
2 changed files with 9 additions and 11 deletions

View File

@ -152,13 +152,12 @@ class sale_order(osv.osv):
invoiced_amount += invoice.amount_total
return invoiced_amount
def _partial_invoiced(self, cursor, user, ids, name, arg, context=None):
def _invoice_exists(self, cursor, user, ids, name, arg, context=None):
res = {}
for sale in self.browse(cursor, user, ids, context=context):
res[sale.id] = True
invoiced_amount = self._get_invoiced_amount(cursor, user, sale, context=context)
if not invoiced_amount or invoiced_amount == sale.amount_total and sale.invoiced:
res[sale.id] = False
res[sale.id] = False
if sale.invoice_ids:
res[sale.id] = True
return res
def _invoiced(self, cursor, user, ids, name, arg, context=None):
@ -172,8 +171,7 @@ class sale_order(osv.osv):
if invoice.state != 'paid':
res[sale.id] = False
break
invoiced_amount = self._get_invoiced_amount(cursor, user, sale, context=context)
if invoiced_amount != sale.amount_total and not invoice_existence:
if not invoice_existence or sale.state == 'manual':
res[sale.id] = False
return res
@ -262,8 +260,8 @@ class sale_order(osv.osv):
'invoiced_rate': fields.function(_invoiced_rate, string='Invoiced', type='float'),
'invoiced': fields.function(_invoiced, string='Paid',
fnct_search=_invoiced_search, type='boolean', help="It indicates that an invoice has been paid."),
'partial_invoiced': fields.function(_partial_invoiced, string='Partial invoiced',
fnct_search=_invoiced_search, type='boolean', help="It indicates that sale order has been partially invoiced."),
'invoice_exists': fields.function(_invoice_exists, string='Invoiced',
fnct_search=_invoiced_search, type='boolean', help="It indicates that sale order has at least one invoice."),
'note': fields.text('Terms and conditions'),
'amount_untaxed': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Untaxed Amount',

View File

@ -163,7 +163,7 @@
<button name="action_button_confirm" states="draft" string="Confirm" type="object"/>
<button name="action_button_confirm" states="sent" string="Confirm" class="oe_highlight" type="object"/>
<button name="action_view_invoice" string="View Invoice" type="object" class="oe_highlight"
attrs="{'invisible': ['|', '|', '|', ('state', 'not in',('progress','manual')), ('invoiced', '=', True), ('partial_invoiced', '=', False), ('order_policy','=','picking')]}"/>
attrs="{'invisible': ['|', '|', '|', ('state', 'not in',('progress','manual')), ('invoiced', '=', True), ('invoice_exists', '=', False), ('order_policy','=','picking')]}"/>
<button name="action_view_delivery" string="View Delivery Order" type="object" class="oe_highlight"
attrs="{'invisible': ['|','|','|',('picking_ids','=',False),('picking_ids','=',[]), ('state', 'not in', ('progress','manual')),('shipped','=',True)]}"/>
<button name="%(action_view_sale_advance_payment_inv)d" string="Create Invoice"
@ -320,7 +320,7 @@
<group>
<field name="invoiced"/>
<field name="shipped"/>
<field name="partial_invoiced"/>
<field name="invoice_exists"/>
</group>
</group>
</page>