-
-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] contract: Template lines handling #92
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 LasLabs Inc. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountAnalyticContractLine(models.Model): | ||
|
||
_name = 'account.analytic.contract.line' | ||
_description = 'Contract Lines' | ||
_inherit = 'account.analytic.invoice.line' | ||
|
||
analytic_account_id = fields.Many2one( | ||
string='Contract', | ||
comodel_name='account.analytic.contract', | ||
required=True, | ||
ondelete='cascade', | ||
) | ||
|
||
@api.multi | ||
@api.onchange('product_id') | ||
def _onchange_product_id(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this extra method is needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I guess alternatively I could just add some try/excepts in the invoice line. I'll try that |
||
if not self.product_id: | ||
return {'domain': {'uom_id': []}} | ||
|
||
vals = {} | ||
domain = {'uom_id': [ | ||
('category_id', '=', self.product_id.uom_id.category_id.id)]} | ||
if not self.uom_id or (self.product_id.uom_id.category_id.id != | ||
self.uom_id.category_id.id): | ||
vals['uom_id'] = self.product_id.uom_id | ||
|
||
product = self.product_id.with_context( | ||
lang=self.env.user.partner_id.lang, | ||
partner=self.env.user.partner_id.id, | ||
quantity=self.quantity, | ||
date=fields.Datetime.now(), | ||
pricelist=self.analytic_account_id.pricelist_id.id, | ||
uom=self.uom_id.id, | ||
) | ||
|
||
name = product.name_get()[0][1] | ||
if product.description_sale: | ||
name += '\n' + product.description_sale | ||
vals['name'] = name | ||
|
||
vals['price_unit'] = product.price | ||
self.update(vals) | ||
return {'domain': domain} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# © 2014 Angel Moya <angel.moya@domatix.com> | ||
# © 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com> | ||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> | ||
# Copyright 2016 LasLabs Inc. | ||
# Copyright 2016-2017 LasLabs Inc. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
@@ -16,23 +16,44 @@ class AccountAnalyticInvoiceLine(models.Model): | |
_name = 'account.analytic.invoice.line' | ||
|
||
product_id = fields.Many2one( | ||
'product.product', string='Product', required=True) | ||
'product.product', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reviewers - sorry I killed the diff here - I was having a hard time auditing the fields for required, etc. so had to clean up the spacing |
||
string='Product', | ||
required=True, | ||
) | ||
analytic_account_id = fields.Many2one( | ||
'account.analytic.account', string='Analytic Account') | ||
name = fields.Text(string='Description', required=True) | ||
quantity = fields.Float(default=1.0, required=True) | ||
'account.analytic.account', | ||
string='Analytic Account', | ||
required=True, | ||
ondelete='cascade', | ||
) | ||
name = fields.Text( | ||
string='Description', | ||
required=True, | ||
) | ||
quantity = fields.Float( | ||
default=1.0, | ||
required=True, | ||
) | ||
uom_id = fields.Many2one( | ||
'product.uom', string='Unit of Measure', required=True) | ||
price_unit = fields.Float('Unit Price', required=True) | ||
'product.uom', | ||
string='Unit of Measure', | ||
required=True, | ||
) | ||
price_unit = fields.Float( | ||
'Unit Price', | ||
required=True, | ||
) | ||
price_subtotal = fields.Float( | ||
compute='_compute_price_subtotal', | ||
digits=dp.get_precision('Account'), | ||
string='Sub Total') | ||
string='Sub Total', | ||
) | ||
discount = fields.Float( | ||
string='Discount (%)', | ||
digits=dp.get_precision('Discount'), | ||
help='Discount that is applied in generated invoices.' | ||
' It should be less or equal to 100') | ||
' It should be less or equal to 100', | ||
) | ||
|
||
@api.multi | ||
@api.depends('quantity', 'price_unit', 'discount') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module version should raise at least to
10.0.1.2.0
, but this can be considered a huge change and it should be10.0.2.0.0