[MERGE] forward port of branch 'saas-7' into saas-9 up to revision 7853c9c7bb

This commit is contained in:
qdp-odoo
2016-04-01 14:50:57 +02:00
9 changed files with 50 additions and 31 deletions
+4 -7
View File
@@ -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
+3 -2
View File
@@ -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)
+1 -1
View File
@@ -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'),
+5 -7
View File
@@ -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>
</odoo>
+1 -1
View File
@@ -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",),
}
+9 -4
View File
@@ -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:
+15 -8
View File
@@ -527,19 +527,26 @@ class PurchaseOrderLine(models.Model):
date_order = fields.Datetime(related='order_id.date_order', string='Order Date', readonly=True)
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 '',
+11
View File
@@ -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)
@@ -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">