12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- # -*- encoding: utf-8 -*-
- from openerp import models, fields, api, tools, _
- from openerp.exceptions import Warning
- class account_invoice(models.Model):
- _inherit = 'account.invoice'
- street = fields.Char(string="Calle", compute="_get_partner_data")
- state_id = fields.Many2one('res.country.state',string="Departamento", compute="_get_partner_data")
- country_id = fields.Many2one('res.country',string="País", compute="_get_partner_data")
- email = fields.Char(string="Email", compute="_get_partner_data")
- phone = fields.Char(string="Teléfono", compute="_get_partner_data")
- mobile = fields.Char(string="Celular", compute="_get_partner_data")
- credit_limit = fields.Float(string="Límite de crédito", compute="_get_partner_data")
- @api.onchange('partner_id')
- def onchange_partner_id(self):
- res = super(account_invoice, self).onchange_partner_id(self.type, self.partner_id.id, self.date_invoice,self.payment_term, self.partner_bank_id.id, self.company_id.id)
- if type(res) is dict and res.has_key('value'):
- for field, value in res.get('value').items():
- if hasattr(self, field):
- setattr(self, field, value)
- if self.partner_id:
- domain = [('id', '=', self.partner_id.id)]
- partner = self.env['res.partner'].search(domain)
- self.street = partner.street
- self.state_id = partner.state_id and partner.state_id.id or False
- self.country_id = partner.country_id and partner.country_id.id or False
- self.email = partner.email
- self.phone = partner.phone
- self.mobile = partner.mobile
- self.credit_limit = partner.credit_limit
- return res
- @api.one
- def _get_partner_data(self):
- domain = [('id', '=', self.partner_id.id)]
- partner = self.env['res.partner'].search(domain)
- self.street = partner.street
- self.state_id = partner.state_id and partner.state_id.id or False
- self.country_id = partner.country_id and partner.country_id.id or False
- self.email = partner.email
- self.phone = partner.phone
- self.mobile = partner.mobile
- self.credit_limit = partner.credit_limit
|