mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[ADD] agreement_stock
This commit is contained in:
committed by
Maxime Chambreuil
parent
b562ee210a
commit
3c7cc05c34
7
agreement_stock/models/__init__.py
Normal file
7
agreement_stock/models/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# Copyright (C) 2018 - TODAY, Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import (
|
||||
stock,
|
||||
agreement,
|
||||
)
|
||||
43
agreement_stock/models/agreement.py
Normal file
43
agreement_stock/models/agreement.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Copyright (C) 2018 - TODAY, Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class Agreement(models.Model):
|
||||
_inherit = "agreement"
|
||||
|
||||
picking_count = fields.Integer('# Pickings',
|
||||
compute='_compute_picking_count')
|
||||
move_count = fields.Integer('# Moves', compute='_compute_move_count')
|
||||
lot_count = fields.Integer('# Lots/Serials', compute='_compute_lot_count')
|
||||
|
||||
@api.multi
|
||||
def _compute_picking_count(self):
|
||||
data = self.env['stock.picking'].read_group(
|
||||
[('agreement_id', 'in', self.ids)],
|
||||
['agreement_id'], ['agreement_id'])
|
||||
count_data = dict((item['agreement_id'][0],
|
||||
item['agreement_id_count']) for item in data)
|
||||
for agreement in self:
|
||||
agreement.picking_count = count_data.get(agreement.id, 0)
|
||||
|
||||
@api.multi
|
||||
def _compute_move_count(self):
|
||||
data = self.env['stock.move'].read_group(
|
||||
[('agreement_id', 'in', self.ids)],
|
||||
['agreement_id'], ['agreement_id'])
|
||||
count_data = dict((item['agreement_id'][0],
|
||||
item['agreement_id_count']) for item in data)
|
||||
for agreement in self:
|
||||
agreement.move_count = count_data.get(agreement.id, 0)
|
||||
|
||||
@api.multi
|
||||
def _compute_lot_count(self):
|
||||
data = self.env['stock.production.lot'].read_group(
|
||||
[('agreement_id', 'in', self.ids)],
|
||||
['agreement_id'], ['agreement_id'])
|
||||
count_data = dict((item['agreement_id'][0],
|
||||
item['agreement_id_count']) for item in data)
|
||||
for agreement in self:
|
||||
agreement.lot_count = count_data.get(agreement.id, 0)
|
||||
27
agreement_stock/models/stock.py
Normal file
27
agreement_stock/models/stock.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2018 - TODAY, Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
_inherit = "stock.picking"
|
||||
|
||||
agreement_id = fields.Many2one('agreement', 'Agreement')
|
||||
|
||||
|
||||
class StockMove(models.Model):
|
||||
_inherit = "stock.move"
|
||||
|
||||
agreement_id = fields.Many2one('agreement',
|
||||
related='picking_id.agreement_id',
|
||||
string='Agreement',
|
||||
store=True)
|
||||
|
||||
|
||||
class StockProductionLot(models.Model):
|
||||
_inherit = "stock.production.lot"
|
||||
|
||||
agreement_id = fields.Many2one('agreement', 'Agreement')
|
||||
serviceprofile_id = fields.Many2one('agreement.serviceprofile',
|
||||
'Service Profile')
|
||||
Reference in New Issue
Block a user