[MERGE] forward port branch 9.0 up to a7531810f3
This commit is contained in:
@@ -42,7 +42,7 @@ class AccountInvoice(models.Model):
|
||||
_order = "date_invoice desc, number desc, id desc"
|
||||
|
||||
@api.one
|
||||
@api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'currency_id', 'company_id', 'date_invoice')
|
||||
@api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'currency_id', 'company_id', 'date_invoice', 'type')
|
||||
def _compute_amount(self):
|
||||
self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line_ids)
|
||||
self.amount_tax = sum(line.amount for line in self.tax_line_ids)
|
||||
|
||||
@@ -708,7 +708,7 @@ class PosOrderLine(models.Model):
|
||||
return line
|
||||
|
||||
company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.user.company_id)
|
||||
name = fields.Char(string='Line No', required=True, copy=False, default=lambda self: self.env['ir.sequence'].next_by_code('pos.order.line'))
|
||||
name = fields.Char(string='Line No', required=True, copy=False)
|
||||
notice = fields.Char(string='Discount Notice')
|
||||
product_id = fields.Many2one('product.product', string='Product', domain=[('sale_ok', '=', True)], required=True, change_default=True)
|
||||
price_unit = fields.Float(string='Unit Price', digits=0)
|
||||
@@ -721,6 +721,31 @@ class PosOrderLine(models.Model):
|
||||
tax_ids = fields.Many2many('account.tax', string='Taxes', readonly=True)
|
||||
tax_ids_after_fiscal_position = fields.Many2many('account.tax', compute='_get_tax_ids_after_fiscal_position', string='Taxes')
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
if values.get('order_id') and not values.get('name'):
|
||||
# set name based on the sequence specified on the config
|
||||
config_id = self.env['pos.order'].browse(values['order_id']).session_id.config_id.id
|
||||
# HACK: sequence created in the same transaction as the config
|
||||
# cf TODO master is pos.config create
|
||||
# remove me saas-15
|
||||
self.env.cr.execute("""
|
||||
SELECT s.id
|
||||
FROM ir_sequence s
|
||||
JOIN pos_config c
|
||||
ON s.create_date=c.create_date
|
||||
WHERE c.id = %s
|
||||
AND s.code = 'pos.order.line'
|
||||
LIMIT 1
|
||||
""", (config_id,))
|
||||
sequence = self.env.cr.fetchone()
|
||||
if sequence:
|
||||
values['name'] = self.env['ir.sequence'].browse(sequence[0])._next()
|
||||
if not values.get('name'):
|
||||
# fallback on any pos.order sequence
|
||||
values['name'] = self.env['ir.sequence'].next_by_code('pos.order.line')
|
||||
return super(PosOrderLine, self).create(values)
|
||||
|
||||
@api.depends('price_unit', 'tax_ids', 'qty', 'discount', 'product_id')
|
||||
def _compute_amount_line_all(self):
|
||||
for line in self:
|
||||
|
||||
@@ -641,15 +641,16 @@ class PurchaseOrderLine(models.Model):
|
||||
diff_quantity = line.product_qty
|
||||
for procurement in line.procurement_ids:
|
||||
procurement_qty = procurement.product_uom._compute_qty_obj(procurement.product_uom, procurement.product_qty, line.product_uom)
|
||||
tmp = template.copy()
|
||||
tmp.update({
|
||||
'product_uom_qty': min(procurement_qty, diff_quantity),
|
||||
'move_dest_id': procurement.move_dest_id.id, #move destination is same as procurement destination
|
||||
'procurement_id': procurement.id,
|
||||
'propagate': procurement.rule_id.propagate,
|
||||
})
|
||||
done += moves.create(tmp)
|
||||
diff_quantity -= min(procurement_qty, diff_quantity)
|
||||
if float_compare(diff_quantity, 0.0, precision_rounding=line.product_uom.rounding) > 0:
|
||||
tmp = template.copy()
|
||||
tmp.update({
|
||||
'product_uom_qty': min(procurement_qty, diff_quantity),
|
||||
'move_dest_id': procurement.move_dest_id.id, #move destination is same as procurement destination
|
||||
'procurement_id': procurement.id,
|
||||
'propagate': procurement.rule_id.propagate,
|
||||
})
|
||||
done += moves.create(tmp)
|
||||
diff_quantity -= min(procurement_qty, diff_quantity)
|
||||
if float_compare(diff_quantity, 0.0, precision_rounding=line.product_uom.rounding) > 0:
|
||||
template['product_uom_qty'] = diff_quantity
|
||||
done += moves.create(template)
|
||||
|
||||
@@ -710,7 +710,7 @@ Model Reference
|
||||
.. automethod:: fields_get
|
||||
.. automethod:: fields_view_get
|
||||
|
||||
.. rubric:: ???
|
||||
.. rubric:: Miscellaneous methods
|
||||
|
||||
.. automethod:: default_get
|
||||
.. automethod:: copy
|
||||
|
||||
Reference in New Issue
Block a user