1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#----------------------------------------------------------
# HS CODE
#----------------------------------------------------------
_logger = logging.getLogger(__name__)
class hscode(models.Model):
_name = 'inno.hscode'
_rec_name = 'description'
code = fields.Char('Code', required=True)
description = fields.Char('Description', required=True)
#----------------------------------------------------------
# Country Origin
#----------------------------------------------------------
class countryorigin(models.Model):
_name = 'inno.countryorigin'
_rec_name = 'description'
code = fields.Char('Code', required=True)
description = fields.Char('Description', required=True)
from openerp.osv import fields, osv
#----------------------------------------------------------
# Products
#----------------------------------------------------------
class product_template(osv.osv):
_inherit = "product.template"
_columns = {
'hscode': fields.many2one('inno.hscode', 'HS CODE', help='HS CODE'),
'countryorigin': fields.many2one('inno.countryorigin', 'Pays Origine', help='Pays Origine')
}
#
# Le problème vient de cette class je pense ! <------------------
#
class account_invoice_line(osv.osv):
_inherit = 'account.invoice.line'
_columns = {
'hscode': fields.many2one('inno.hscode','HS CODE',help='HS CODE'),
'countryorigin': fields.many2one('inno.countryorigin', 'Pays Origine', help='Pays Origine')
}
def _default_account(self):
# XXX this gets the default account for the user's company,
# it should get the default account for the invoice's company
# however, the invoice's company does not reach this point
if self._context.get('type') in ('out_invoice', 'out_refund'):
return self.env['ir.property'].get('property_account_income_categ', 'product.category')
else:
return self.env['ir.property'].get('property_account_expense_categ', 'product.category')
hscode = fields.Many2one('product.hscode', string='Product', ondelete='restrict', index=True)
countryorigin = fields.Many2one('product.countryorigin', string='Product', ondelete='restrict', index=True)
account_invoice_line() |
Partager