Initialize v18 branch

Rename *_usability modules to *_usability_akretion
This commit is contained in:
Alexis de Lattre
2024-12-24 10:11:21 +01:00
parent 9913924202
commit 13744fc404
264 changed files with 50 additions and 87 deletions

View File

@@ -0,0 +1,3 @@
from . import purchase
from . import stock_move
from . import stock_move_line

View File

@@ -0,0 +1,26 @@
# Copyright 2015-2022 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
picking_type_id = fields.Many2one(tracking=True)
incoterm_id = fields.Many2one(tracking=True)
# inherit compute method of the field delivery_partner_id
# defined in purchase_usability
@api.depends('dest_address_id', 'picking_type_id')
def _compute_delivery_partner_id(self):
for o in self:
delivery_partner_id = False
if o.dest_address_id:
delivery_partner_id = o.dest_address_id
elif (
o.picking_type_id.warehouse_id and
o.picking_type_id.warehouse_id.partner_id):
delivery_partner_id = o.picking_type_id.warehouse_id.partner_id
o.delivery_partner_id = delivery_partner_id

View File

@@ -0,0 +1,33 @@
# Copyright 2023 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class StockMove(models.Model):
_inherit = 'stock.move'
# for optional display in tree view
product_supplier_code = fields.Char(
compute='_compute_product_supplier_code', string="Vendor Product Code")
def _compute_product_supplier_code(self):
pso = self.env['product.supplierinfo']
for move in self:
code = False
if move.purchase_line_id and move.purchase_line_id.order_id:
po = move.purchase_line_id.order_id
partner_id = po.partner_id.commercial_partner_id.id
if partner_id:
sinfo = pso.search_read([
('product_tmpl_id', '=', move.product_id.product_tmpl_id.id),
('product_id', 'in', (False, move.product_id.id)),
('partner_id', '=', partner_id),
('product_code', '!=', False),
('company_id', 'in', (False, move.company_id.id)),
], ['product_code'], limit=1, order='product_id')
# if I order by product_id, I get the null values at the end
if sinfo:
code = sinfo[0]['product_code']
move.product_supplier_code = code

View File

@@ -0,0 +1,34 @@
# Copyright 2023 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
# for optional display in tree view
product_supplier_code = fields.Char(
compute='_compute_product_supplier_code', string="Vendor Product Code")
def _compute_product_supplier_code(self):
pso = self.env['product.supplierinfo']
for mline in self:
code = False
move = mline.move_id
if move and move.purchase_line_id and move.purchase_line_id.order_id:
po = move.purchase_line_id.order_id
partner_id = po.partner_id.commercial_partner_id.id
if partner_id:
sinfo = pso.search_read([
('product_tmpl_id', '=', mline.product_id.product_tmpl_id.id),
('product_id', 'in', (False, mline.product_id.id)),
('partner_id', '=', partner_id),
('product_code', '!=', False),
('company_id', 'in', (False, mline.company_id.id)),
], ['product_code'], limit=1, order='product_id')
# if I order by product_id, I get the null values at the end
if sinfo:
code = sinfo[0]['product_code']
mline.product_supplier_code = code