mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-25 00:02:05 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -2,6 +2,5 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import mrp_production
|
||||
from . import stock_picking
|
||||
from . import product_product
|
||||
from . import stock_move
|
||||
|
|
|
|||
|
|
@ -8,9 +8,15 @@ class MrpProduction(models.Model):
|
|||
_inherit = 'mrp.production'
|
||||
|
||||
def _cal_price(self, consumed_moves):
|
||||
finished_move = self.move_finished_ids.filtered(lambda x: x.product_id == self.product_id and x.state not in ('done', 'cancel') and x.quantity_done > 0)
|
||||
finished_move = self.move_finished_ids.filtered(lambda x: x.product_id == self.product_id and x.state not in ('done', 'cancel') and x.quantity > 0)
|
||||
# Take the price unit of the reception move
|
||||
last_done_receipt = finished_move.move_dest_ids.filtered(lambda m: m.state == 'done')[-1:]
|
||||
if last_done_receipt.is_subcontract:
|
||||
self.extra_cost = last_done_receipt._get_price_unit()
|
||||
quantity = last_done_receipt.quantity
|
||||
bill_data = last_done_receipt._get_value_from_account_move(quantity)
|
||||
po_data = last_done_receipt._get_value_from_quotation(quantity - bill_data['quantity'])
|
||||
if not bill_data['value'] and not po_data['value']:
|
||||
self.extra_cost = last_done_receipt.price_unit
|
||||
else:
|
||||
self.extra_cost = (bill_data['value'] + po_data['value']) / quantity
|
||||
return super()._cal_price(consumed_moves=consumed_moves)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
|
|
@ -14,5 +15,5 @@ class ProductProduct(models.Model):
|
|||
seller = self._select_seller(quantity=bom.product_qty, uom_id=bom.product_uom_id, params={'subcontractor_ids': bom.subcontractor_ids})
|
||||
if seller:
|
||||
seller_price = seller.currency_id._convert(seller.price, self.env.company.currency_id, (bom.company_id or self.env.company), fields.Date.today())
|
||||
price += seller.product_uom._compute_price(seller_price, self.uom_id)
|
||||
price += seller.product_uom_id._compute_price(seller_price, self.uom_id)
|
||||
return price
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
|
|
@ -7,6 +6,12 @@ from odoo import models
|
|||
class StockMove(models.Model):
|
||||
_inherit = 'stock.move'
|
||||
|
||||
def _should_force_price_unit(self):
|
||||
self.ensure_one()
|
||||
return self.is_subcontract or super()._should_force_price_unit()
|
||||
def _get_aml_value(self):
|
||||
value = super()._get_aml_value()
|
||||
if (
|
||||
self.production_id
|
||||
and self.move_dest_ids.filtered(lambda m: m.state == "done")[-1:].is_subcontract
|
||||
and self.product_id.cost_method != "standard"
|
||||
):
|
||||
value -= self.production_id.extra_cost * self.product_uom._compute_quantity(self.quantity, self.product_id.uom_id)
|
||||
return value
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
from odoo.osv.expression import OR
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
def action_view_stock_valuation_layers(self):
|
||||
action = super(StockPicking, self).action_view_stock_valuation_layers()
|
||||
subcontracted_productions = self._get_subcontract_production()
|
||||
if not subcontracted_productions:
|
||||
return action
|
||||
domain = action['domain']
|
||||
domain_subcontracting = [('id', 'in', (subcontracted_productions.move_raw_ids | subcontracted_productions.move_finished_ids).stock_valuation_layer_ids.ids)]
|
||||
domain = OR([domain, domain_subcontracting])
|
||||
return dict(action, domain=domain)
|
||||
Loading…
Add table
Add a link
Reference in a new issue