[MERGE] forward port branch saas-15 up to 5701010d0d

This commit is contained in:
Christophe Simonis
2017-12-12 16:15:04 +01:00
8 changed files with 31 additions and 19 deletions
-3
View File
@@ -1339,9 +1339,6 @@ class AccountInvoiceLine(models.Model):
self.price_unit = 0.0 self.price_unit = 0.0
domain['uom_id'] = [] domain['uom_id'] = []
else: else:
# Use the purchase uom by default
self.uom_id = self.product_id.uom_po_id
if part.lang: if part.lang:
product = self.product_id.with_context(lang=part.lang) product = self.product_id.with_context(lang=part.lang)
else: else:
+6 -4
View File
@@ -41,10 +41,12 @@ class ProductProduct(models.Model):
# No attribute_value_ids means the bom line is not variant specific # 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'] price += sbom.product_id.uom_id._compute_price(sbom.product_id.standard_price, sbom.product_uom_id) * sbom_data['qty']
if bom.routing_id: if bom.routing_id:
total_cost = 0.0 # FIXME master: remove me
for order in bom.routing_id.operation_ids: if hasattr(self.env['mrp.workcenter'], 'costs_hour'):
total_cost += (order.time_cycle/60) * order.workcenter_id.costs_hour total_cost = 0.0
price += bom.product_uom_id._compute_price(total_cost, bom.product_id.uom_id) 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 # Convert on product UoM quantities
if price > 0: if price > 0:
price = bom.product_uom_id._compute_price(price / bom.product_qty, self.uom_id) 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 data['account_id'] = account.id
return data 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 # Load all unsold PO lines
@api.onchange('purchase_id') @api.onchange('purchase_id')
def purchase_order_change(self): def purchase_order_change(self):
+5 -7
View File
@@ -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 !')] _sql_constraints = [('barcode_company_uniq', 'unique (barcode,company_id)', 'The barcode for a location must be unique per company !')]
@api.one @api.one
@api.depends('name', 'location_id.name') @api.depends('name', 'location_id.complete_name')
def _compute_complete_name(self): def _compute_complete_name(self):
""" Forms complete name of location from parent location to child location. """ """ Forms complete name of location from parent location to child location. """
name = self.name if self.location_id.complete_name:
current = self self.complete_name = '%s/%s' % (self.location_id.complete_name, self.name)
while current.location_id: else:
current = current.location_id self.complete_name = self.name
name = '%s/%s' % (current.name, name)
self.complete_name = name
@api.multi @api.multi
def name_get(self): def name_get(self):
+5 -2
View File
@@ -179,10 +179,13 @@ class StockMove(models.Model):
else: else:
self.lot_ids = self.mapped('reserved_quant_ids').mapped('lot_id').ids self.lot_ids = self.mapped('reserved_quant_ids').mapped('lot_id').ids
@api.one @api.multi
@api.depends('reserved_quant_ids.qty') @api.depends('reserved_quant_ids.qty')
def _compute_reserved_availability(self): 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.one
@api.depends('state', 'product_id', 'product_qty', 'location_id') @api.depends('state', 'product_id', 'product_qty', 'location_id')
@@ -121,6 +121,8 @@ class website_account(http.Controller):
# vat validation # vat validation
if data.get("vat") and hasattr(request.env["res.partner"], "check_vat"): 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: if request.website.company_id.sudo().vat_check_vies:
# force full VIES online check # force full VIES online check
check_func = request.env["res.partner"].vies_vat_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) return self.env['ir.attachment'].sudo().browse(attachment_ids)
def save_attachment(self, type, content, inc=None): def save_attachment(self, type, content, inc=None):
assert type in ('js', 'css')
ira = self.env['ir.attachment'] ira = self.env['ir.attachment']
fname = '%s%s.%s' % (self.name, ('' if inc is None else '.%s' % inc), type) fname = '%s%s.%s' % (self.name, ('' if inc is None else '.%s' % inc), type)
mimetype = 'application/javascript' if type == 'js' else 'text/css'
values = { values = {
'name': "/web/content/%s" % type, 'name': "/web/content/%s" % type,
'datas_fname': fname, 'datas_fname': fname,
'mimetype' : mimetype,
'res_model': 'ir.ui.view', 'res_model': 'ir.ui.view',
'res_id': False, 'res_id': False,
'type': 'binary', 'type': 'binary',
+3 -3
View File
@@ -977,11 +977,11 @@ class Field(object):
spec = self.modified_draft(record) spec = self.modified_draft(record)
# set value in cache, inverse field, and mark record as dirty # 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: if env.in_onchange:
for invf in record._field_inverses[self]: for invf in record._field_inverses[self]:
invf._update(record[self.name], record) invf._update(record[self.name], record)
record._set_dirty(self.name) env.dirty[record].add(self.name)
# determine more dependent fields, and invalidate them # determine more dependent fields, and invalidate them
if self.relational: if self.relational:
@@ -994,7 +994,7 @@ class Field(object):
record.write({self.name: write_value}) record.write({self.name: write_value})
# Update the cache unless value contains a new record # Update the cache unless value contains a new record
if not (self.relational and not all(value)): if not (self.relational and not all(value)):
record._cache[self] = value env.cache[self][record.id] = value
############################################################################ ############################################################################
# #