[MERGE] forward port branch saas-14 up to 744c2934b3
This commit is contained in:
@@ -1331,9 +1331,6 @@ class AccountInvoiceLine(models.Model):
|
||||
self.price_unit = 0.0
|
||||
domain['uom_id'] = []
|
||||
else:
|
||||
# Use the purchase uom by default
|
||||
self.uom_id = self.product_id.uom_po_id
|
||||
|
||||
if part.lang:
|
||||
product = self.product_id.with_context(lang=part.lang)
|
||||
else:
|
||||
|
||||
@@ -41,10 +41,12 @@ class ProductProduct(models.Model):
|
||||
# No attribute_value_ids means the bom line is not variant specific
|
||||
price += sbom.product_id.uom_id._compute_price(sbom.product_id.standard_price, sbom.product_uom_id) * sbom_data['qty']
|
||||
if bom.routing_id:
|
||||
total_cost = 0.0
|
||||
for order in bom.routing_id.operation_ids:
|
||||
total_cost += (order.time_cycle/60) * order.workcenter_id.costs_hour
|
||||
price += bom.product_uom_id._compute_price(total_cost, bom.product_id.uom_id)
|
||||
# FIXME master: remove me
|
||||
if hasattr(self.env['mrp.workcenter'], 'costs_hour'):
|
||||
total_cost = 0.0
|
||||
for order in bom.routing_id.operation_ids:
|
||||
total_cost += (order.time_cycle/60) * order.workcenter_id.costs_hour
|
||||
price += bom.product_uom_id._compute_price(total_cost, bom.product_id.uom_id)
|
||||
# Convert on product UoM quantities
|
||||
if price > 0:
|
||||
price = bom.product_uom_id._compute_price(price / bom.product_qty, self.uom_id)
|
||||
|
||||
@@ -59,6 +59,13 @@ class AccountInvoice(models.Model):
|
||||
data['account_id'] = account.id
|
||||
return data
|
||||
|
||||
def _onchange_product_id(self):
|
||||
domain = super(AccountInvoice, self)._onchange_product_id()
|
||||
if self.purchase_id:
|
||||
# Use the purchase uom by default
|
||||
self.uom_id = self.product_id.uom_po_id
|
||||
return domain
|
||||
|
||||
# Load all unsold PO lines
|
||||
@api.onchange('purchase_id')
|
||||
def purchase_order_change(self):
|
||||
|
||||
@@ -70,15 +70,13 @@ class Location(models.Model):
|
||||
_sql_constraints = [('barcode_company_uniq', 'unique (barcode,company_id)', 'The barcode for a location must be unique per company !')]
|
||||
|
||||
@api.one
|
||||
@api.depends('name', 'location_id.name')
|
||||
@api.depends('name', 'location_id.complete_name')
|
||||
def _compute_complete_name(self):
|
||||
""" Forms complete name of location from parent location to child location. """
|
||||
name = self.name
|
||||
current = self
|
||||
while current.location_id:
|
||||
current = current.location_id
|
||||
name = '%s/%s' % (current.name, name)
|
||||
self.complete_name = name
|
||||
if self.location_id.complete_name:
|
||||
self.complete_name = '%s/%s' % (self.location_id.complete_name, self.name)
|
||||
else:
|
||||
self.complete_name = self.name
|
||||
|
||||
@api.multi
|
||||
def name_get(self):
|
||||
|
||||
@@ -179,10 +179,13 @@ class StockMove(models.Model):
|
||||
else:
|
||||
self.lot_ids = self.mapped('reserved_quant_ids').mapped('lot_id').ids
|
||||
|
||||
@api.one
|
||||
@api.multi
|
||||
@api.depends('reserved_quant_ids.qty')
|
||||
def _compute_reserved_availability(self):
|
||||
self.reserved_availability = sum(self.mapped('reserved_quant_ids').mapped('qty'))
|
||||
result = {data['reservation_id'][0]: data['qty'] for data in
|
||||
self.env['stock.quant'].read_group([('reservation_id', 'in', self.ids)], ['reservation_id','qty'], ['reservation_id'])}
|
||||
for rec in self:
|
||||
rec.reserved_availability = result.get(rec.id, 0.0)
|
||||
|
||||
@api.one
|
||||
@api.depends('state', 'product_id', 'product_qty', 'location_id')
|
||||
|
||||
@@ -121,6 +121,8 @@ class website_account(http.Controller):
|
||||
|
||||
# vat validation
|
||||
if data.get("vat") and hasattr(request.env["res.partner"], "check_vat"):
|
||||
if data.get("country_id"):
|
||||
data["vat"] = request.env["res.partner"].fix_eu_vat_number(int(data.get("country_id")), data.get("vat"))
|
||||
if request.website.company_id.sudo().vat_check_vies:
|
||||
# force full VIES online check
|
||||
check_func = request.env["res.partner"].vies_vat_check
|
||||
|
||||
@@ -198,12 +198,15 @@ class AssetsBundle(object):
|
||||
return self.env['ir.attachment'].sudo().browse(attachment_ids)
|
||||
|
||||
def save_attachment(self, type, content, inc=None):
|
||||
assert type in ('js', 'css')
|
||||
ira = self.env['ir.attachment']
|
||||
|
||||
fname = '%s%s.%s' % (self.name, ('' if inc is None else '.%s' % inc), type)
|
||||
mimetype = 'application/javascript' if type == 'js' else 'text/css'
|
||||
values = {
|
||||
'name': "/web/content/%s" % type,
|
||||
'datas_fname': fname,
|
||||
'mimetype' : mimetype,
|
||||
'res_model': 'ir.ui.view',
|
||||
'res_id': False,
|
||||
'type': 'binary',
|
||||
|
||||
+3
-3
@@ -974,11 +974,11 @@ class Field(object):
|
||||
spec = self.modified_draft(record)
|
||||
|
||||
# set value in cache, inverse field, and mark record as dirty
|
||||
record._cache[self] = value
|
||||
env.cache[self][record.id] = value
|
||||
if env.in_onchange:
|
||||
for invf in record._field_inverses[self]:
|
||||
invf._update(record[self.name], record)
|
||||
record._set_dirty(self.name)
|
||||
env.dirty[record].add(self.name)
|
||||
|
||||
# determine more dependent fields, and invalidate them
|
||||
if self.relational:
|
||||
@@ -991,7 +991,7 @@ class Field(object):
|
||||
record.write({self.name: write_value})
|
||||
# Update the cache unless value contains a new record
|
||||
if not (self.relational and not all(value)):
|
||||
record._cache[self] = value
|
||||
env.cache[self][record.id] = value
|
||||
|
||||
############################################################################
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user