diff options
| author | qdp-odoo <qdp@odoo.com> | 2016-04-01 14:50:57 +0200 |
|---|---|---|
| committer | qdp-odoo <qdp@odoo.com> | 2016-04-01 14:50:57 +0200 |
| commit | 2b039c7643350e961bcf032ffd9e97a039eeab35 (patch) | |
| tree | 6833b499bb3492ccb42b00a9da4e8f62071b6c2a /addons | |
| parent | 17f4d2259457d76d5d99f6d846cbec75e6f94692 (diff) | |
| parent | 7853c9c7bb7e3155606b3986577e757fc9843c4d (diff) | |
[MERGE] forward port of branch 'saas-7' into saas-9 up to revision 7853c9c7bb7e3155606b3986577e757fc9843c4d
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/models/account.py | 11 | ||||
| -rw-r--r-- | addons/account/models/account_invoice.py | 5 | ||||
| -rw-r--r-- | addons/account_voucher/account_voucher.py | 2 | ||||
| -rw-r--r-- | addons/project_issue/project_dashboard.xml | 12 | ||||
| -rw-r--r-- | addons/project_issue/project_issue.py | 2 | ||||
| -rw-r--r-- | addons/purchase/invoice.py | 13 | ||||
| -rw-r--r-- | addons/purchase/purchase.py | 23 | ||||
| -rw-r--r-- | addons/purchase/stock.py | 11 | ||||
| -rw-r--r-- | addons/website_hr_recruitment/views/templates.xml | 2 |
9 files changed, 50 insertions, 31 deletions
diff --git a/addons/account/models/account.py b/addons/account/models/account.py index e8fca4da215..63331b30d42 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -635,7 +635,7 @@ class AccountTax(models.Model): # the 'Account' decimal precision + 5), and that way it's like # rounding after the sum of the tax amounts of each line prec = currency.decimal_places - if company_id.tax_calculation_rounding_method == 'round_globally': + if company_id.tax_calculation_rounding_method == 'round_globally' or not bool(self.env.context.get("round", True)): prec += 5 total_excluded = total_included = base = round(price_unit * quantity, prec) @@ -650,7 +650,7 @@ class AccountTax(models.Model): continue tax_amount = tax._compute_amount(base, price_unit, quantity, product, partner) - if company_id.tax_calculation_rounding_method == 'round_globally': + if company_id.tax_calculation_rounding_method == 'round_globally' or not bool(self.env.context.get("round", True)): tax_amount = round(tax_amount, prec) else: tax_amount = currency.round(tax_amount) @@ -676,8 +676,8 @@ class AccountTax(models.Model): return { 'taxes': sorted(taxes, key=lambda k: k['sequence']), - 'total_excluded': currency.round(total_excluded), - 'total_included': currency.round(total_included), + 'total_excluded': currency.round(total_excluded) if bool(self.env.context.get("round", True)) else total_excluded, + 'total_included': currency.round(total_included) if bool(self.env.context.get("round", True)) else total_included, 'base': base, } @@ -733,6 +733,3 @@ class AccountOperationTemplate(models.Model): @api.onchange('name') def onchange_name(self): self.label = self.name - - - diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 4e272e1543b..1f0b4500cf4 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1068,7 +1068,7 @@ class AccountInvoiceLine(models.Model): required=True, domain=[('deprecated', '=', False)], default=_default_account, help="The income or expense account related to the selected product.") - price_unit = fields.Monetary(string='Unit Price', required=True) + price_unit = fields.Float(string='Unit Price', required=True, digits=dp.get_precision('Product Price')) price_subtotal = fields.Monetary(string='Amount', store=True, readonly=True, compute='_compute_price') price_subtotal_signed = fields.Monetary(string='Amount Signed', currency_field='company_currency_id', @@ -1126,7 +1126,8 @@ class AccountInvoiceLine(models.Model): fix_price = self.env['account.tax']._fix_tax_included_price if self.invoice_id.type in ('in_invoice', 'in_refund'): - if not self.price_unit or float_compare(self.price_unit, self.product_id.standard_price, precision_digits=self.currency_id.rounding) == 0: + prec = self.env['decimal.precision'].precision_get('Product Price') + if not self.price_unit or float_compare(self.price_unit, self.product_id.standard_price, precision_digits=prec) == 0: self.price_unit = fix_price(self.product_id.standard_price, taxes, fp_taxes) else: self.price_unit = fix_price(self.product_id.lst_price, taxes, fp_taxes) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index d9073b0c737..79110eb2041 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -322,7 +322,7 @@ class account_voucher_line(models.Model): account_id = fields.Many2one('account.account', string='Account', required=True, domain=[('deprecated', '=', False)], help="The income or expense account related to the selected product.") - price_unit = fields.Monetary(string='Unit Price', required=True, oldname='amount') + price_unit = fields.Float(string='Unit Price', required=True, digits=dp.get_precision('Product Price'), oldname='amount') price_subtotal = fields.Monetary(string='Amount', store=True, readonly=True, compute='_compute_subtotal') quantity = fields.Float(digits=dp.get_precision('Product Unit of Measure'), diff --git a/addons/project_issue/project_dashboard.xml b/addons/project_issue/project_dashboard.xml index 381a6173026..b7197fa086d 100644 --- a/addons/project_issue/project_dashboard.xml +++ b/addons/project_issue/project_dashboard.xml @@ -10,15 +10,13 @@ <field name="issue_needaction_count" invisible="1"/> </field> <xpath expr="//div/a[contains(@class, 'o_project_kanban_box')]" position="after"> - <div t-if="record.use_issues.raw_value" class="o_project_kanban_box"> - <a name="%(act_project_project_2_project_issue_all)d" type="action"> - <span class="o_value"><t t-raw="record.issue_ids.raw_value.length"/></span> - <span class="o_label"><field name="label_issues"/></span> - </a> + <a t-if="record.use_issues.raw_value" class="o_project_kanban_box" name="%(act_project_project_2_project_issue_all)d" type="action"> + <span class="o_value"><t t-raw="record.issue_ids.raw_value.length"/></span> + <span class="o_label"><field name="label_issues"/></span> <a t-if="record.issue_needaction_count.raw_value" class="o_needaction" name="%(act_project_project_2_project_issue_all)d" type="action" context="{'search_default_message_needaction': 1}"> <t t-esc="record.issue_needaction_count.raw_value"/> </a> - </div> + </a> </xpath> <xpath expr="//div[contains(@class, 'o_kanban_manage_reports')]" position="inside"> @@ -29,4 +27,4 @@ </field> </record> -</odoo>
\ No newline at end of file +</odoo> diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index f5dabcc2ba4..2699625bd79 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -483,7 +483,7 @@ class project(osv.Model): _columns = { 'issue_count': fields.function(_issue_count, type='integer', string="Issues",), 'issue_ids': fields.one2many('project.issue', 'project_id', string="Issues", - domain=[('stage_id.fold', '=', False)]), + domain=['|', ('stage_id.fold', '=', False), ('stage_id', '=', False)]), 'issue_needaction_count': fields.function(_issue_needaction_count, type='integer', string="Issues",), } diff --git a/addons/purchase/invoice.py b/addons/purchase/invoice.py index 8666e3eea97..be9df270348 100644 --- a/addons/purchase/invoice.py +++ b/addons/purchase/invoice.py @@ -58,7 +58,7 @@ class AccountInvoice(models.Model): 'uom_id': line.product_uom.id, 'product_id': line.product_id.id, 'account_id': self.env['account.invoice.line'].with_context({'journal_id': self.journal_id.id, 'type': 'in_invoice'})._default_account(), - 'price_unit': line.order_id.currency_id.compute(line.price_unit, self.currency_id), + 'price_unit': line.order_id.currency_id.compute(line.price_unit, self.currency_id, round=False), 'quantity': qty, 'discount': 0.0, 'account_analytic_id': line.account_analytic_id.id, @@ -79,7 +79,7 @@ class AccountInvoice(models.Model): def _onchange_currency_id(self): if self.currency_id: for line in self.invoice_line_ids.filtered(lambda r: r.purchase_line_id): - line.price_unit = line.purchase_id.currency_id.compute(line.purchase_line_id.price_unit, self.currency_id) + line.price_unit = line.purchase_id.currency_id.compute(line.purchase_line_id.price_unit, self.currency_id, round=False) @api.onchange('invoice_line_ids') def _onchange_origin(self): @@ -126,9 +126,14 @@ class AccountInvoice(models.Model): if i_line.product_id.cost_method != 'standard' and i_line.purchase_line_id: #for average/fifo/lifo costing method, fetch real cost price from incomming moves stock_move_obj = self.env['stock.move'] - valuation_stock_move = stock_move_obj.search([('purchase_line_id', '=', i_line.purchase_line_id.id)], limit=1) + valuation_stock_move = stock_move_obj.search([('purchase_line_id', '=', i_line.purchase_line_id.id), ('state', '=', 'done')]) if valuation_stock_move: - valuation_price_unit = valuation_stock_move[0].price_unit + valuation_price_unit_total = 0 + valuation_total_qty = 0 + for val_stock_move in valuation_stock_move: + valuation_price_unit_total += val_stock_move.price_unit * val_stock_move.product_qty + valuation_total_qty += val_stock_move.product_qty + valuation_price_unit = valuation_price_unit_total / valuation_total_qty if inv.currency_id.id != company_currency.id: valuation_price_unit = company_currency.with_context(date=inv.date_invoice).compute(valuation_price_unit, inv.currency_id) if valuation_price_unit != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc: diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 744cae10a28..a154fe1c55b 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -528,18 +528,25 @@ class PurchaseOrderLine(models.Model): procurement_ids = fields.One2many('procurement.order', 'purchase_line_id', string='Associated Procurements', copy=False) @api.multi + def _get_stock_move_price_unit(self): + self.ensure_one() + line = self[0] + order = line.order_id + price_unit = line.price_unit + if line.taxes_id: + price_unit = line.taxes_id.with_context(round=False).compute_all(price_unit, currency=line.order_id.currency_id, quantity=1.0)['total_excluded'] + if line.product_uom.id != line.product_id.uom_id.id: + price_unit *= line.product_uom.factor / line.product_id.uom_id.factor + if order.currency_id != order.company_id.currency_id: + price_unit = order.currency_id.compute(price_unit, order.company_id.currency_id, round=False) + return price_unit + + @api.multi def _create_stock_moves(self, picking): moves = self.env['stock.move'] done = self.env['stock.move'].browse() for line in self: - order = line.order_id - price_unit = line.price_unit - if line.taxes_id: - price_unit = line.taxes_id.compute_all(price_unit, currency=line.order_id.currency_id, quantity=1.0)['total_excluded'] - if line.product_uom.id != line.product_id.uom_id.id: - price_unit *= line.product_uom.factor / line.product_id.uom_id.factor - if order.currency_id != order.company_id.currency_id: - price_unit = order.currency_id.compute(price_unit, order.company_id.currency_id, round=False) + price_unit = line._get_stock_move_price_unit() template = { 'name': line.name or '', diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 3f8faa53d3c..38f656bc913 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -32,6 +32,17 @@ class stock_move(osv.osv): def get_price_unit(self, cr, uid, move, context=None): """ Returns the unit price to store on the quant """ if move.purchase_line_id: + order = move.purchase_line_id.order_id + #if the currency of the PO is different than the company one, the price_unit on the move must be reevaluated + #(was created at the rate of the PO confirmation, but must be valuated at the rate of stock move execution) + if order.currency_id != move.company_id.currency_id: + #we don't pass the move.date in the compute() for the currency rate on purpose because + # 1) get_price_unit() is supposed to be called only through move.action_done(), + # 2) the move hasn't yet the correct date (currently it is the expected date, after + # completion of action_done() it will be now() ) + price_unit = move.purchase_line_id._get_stock_move_price_unit() + move.write({'price_unit': price_unit}) + return price_unit return move.price_unit return super(stock_move, self).get_price_unit(cr, uid, move, context=context) diff --git a/addons/website_hr_recruitment/views/templates.xml b/addons/website_hr_recruitment/views/templates.xml index 9165c7992f4..3ac6736a7e2 100644 --- a/addons/website_hr_recruitment/views/templates.xml +++ b/addons/website_hr_recruitment/views/templates.xml @@ -166,7 +166,7 @@ <label class="control-label" for="email_from">Your Email</label> </div> <div class="col-md-7 col-sm-8"> - <input type="text" class="form-control o_website_form_input" name="email_from" required=""/> + <input type="email" class="form-control o_website_form_input" name="email_from" required=""/> </div> </div> <div class="form-group form-field o_website_form_required_custom"> |
