mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-25 08:02:07 +02:00
Initial commit: Accounting packages
This commit is contained in:
commit
4ef34c2317
2661 changed files with 1709616 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# 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
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
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)
|
||||
# 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()
|
||||
return super()._cal_price(consumed_moves=consumed_moves)
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def _compute_bom_price(self, bom, boms_to_recompute=False, byproduct_bom=False):
|
||||
""" Add the price of the subcontracting supplier if it exists with the bom configuration.
|
||||
"""
|
||||
price = super()._compute_bom_price(bom, boms_to_recompute, byproduct_bom)
|
||||
if bom and bom.type == 'subcontract':
|
||||
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)
|
||||
return price
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
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()
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# -*- 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