mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[FIX] tests and use new api
This commit is contained in:
@@ -9,7 +9,6 @@ from odoo import _, api, exceptions, fields, models
|
||||
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
|
||||
_inherit = "account.invoice"
|
||||
|
||||
claim_id = fields.Many2one('crm.claim', string='Claim')
|
||||
@@ -34,14 +33,13 @@ class AccountInvoice(models.Model):
|
||||
# For each lines replace quantity and add claim_line_id
|
||||
inv_line = claim_line.invoice_line_id
|
||||
clean_line = {}
|
||||
for field_name, field in inv_line._all_columns.iteritems():
|
||||
column_type = field.column._type
|
||||
if column_type == 'many2one':
|
||||
for field_name, field in inv_line._fields.iteritems():
|
||||
if isinstance(field, fields.Many2one):
|
||||
clean_line[field_name] = inv_line[field_name].id
|
||||
elif column_type not in ('many2many', 'one2many'):
|
||||
elif not isinstance(field, (fields.Many2many,
|
||||
fields.One2many)):
|
||||
clean_line[field_name] = inv_line[field_name]
|
||||
elif field_name == 'invoice_line_tax_id':
|
||||
|
||||
tax_ids = inv_line[field_name].ids
|
||||
clean_line[field_name] = [(6, 0, tax_ids)]
|
||||
clean_line['quantity'] = claim_line.product_returned_quantity
|
||||
|
||||
@@ -25,7 +25,7 @@ class ClaimLine(models.Model):
|
||||
|
||||
_inherit = 'mail.thread'
|
||||
_description = "List of product to return"
|
||||
_rec_name = "display_name"
|
||||
# _rec_name = "display_name"
|
||||
|
||||
SUBJECT_LIST = [('none', 'Not specified'),
|
||||
('legal', 'Legal retractation'),
|
||||
@@ -47,6 +47,11 @@ class ClaimLine(models.Model):
|
||||
('expired', _("Expired")),
|
||||
('not_define', _("Not Defined"))]
|
||||
|
||||
@api.model
|
||||
def get_warranty_return_partner(self):
|
||||
return self.env['product.supplierinfo'].fields_get(
|
||||
'warranty_return_partner')['warranty_return_partner']['selection']
|
||||
|
||||
number = fields.Char(
|
||||
readonly=True,
|
||||
default='/',
|
||||
@@ -57,7 +62,7 @@ class ClaimLine(models.Model):
|
||||
default=lambda self: self.env['res.company']._company_default_get(
|
||||
'claim.line'))
|
||||
date = fields.Date('Claim Line Date',
|
||||
select=True,
|
||||
index=True,
|
||||
default=fields.date.today())
|
||||
name = fields.Char('Description', default='none', required=False,
|
||||
help="More precise description of the problem")
|
||||
@@ -114,11 +119,6 @@ class ClaimLine(models.Model):
|
||||
help="If warranty has expired")
|
||||
display_name = fields.Char('Name', compute='_compute_display_name')
|
||||
|
||||
@api.model
|
||||
def get_warranty_return_partner(self):
|
||||
return self.env['product.supplierinfo'].fields_get(
|
||||
'warranty_return_partner')['warranty_return_partner']['selection']
|
||||
|
||||
warranty_type = fields.Selection(
|
||||
get_warranty_return_partner,
|
||||
help="Who is in charge of the warranty return treatment towards "
|
||||
@@ -404,6 +404,7 @@ class ClaimLine(models.Model):
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
@api.depends('claim_id.code', 'name')
|
||||
def _compute_display_name(self):
|
||||
for line_id in self:
|
||||
line_id.display_name = "%s - %s" % (
|
||||
|
||||
Reference in New Issue
Block a user