Compare commits

..

5 Commits

Author SHA1 Message Date
Sébastien BEAU
7b8709a425 Add product_editable_sequence 2025-01-23 12:14:40 +01:00
Alexis de Lattre
1d96cc4c83 stock_usability: add tracking on important fields of stock.production.lot
Code cleanup
2024-12-19 17:30:14 +01:00
beau sebastien
2ff3ea6dcd Merge pull request #214 from akretion/14.0-fix-product_usability
product_usability: seller_id can not be store as muti-company will be broken
2024-12-12 01:39:21 +01:00
Sébastien BEAU
a1f8ab32dd product_usability: make the field seller_id searcheable 2024-12-12 01:38:25 +01:00
Sébastien BEAU
0fa2024dab product_usability: seller_id can not be store as muti-company will be broken
do not store the field as shared product can have different supplier
depending on the company logged
Use compute as related will always pick the first one whatever the
company logged
2024-06-02 22:25:10 +02:00
10 changed files with 92 additions and 11 deletions

View File

@@ -21,12 +21,10 @@ class AccountMoveReversal(models.TransientModel):
moves = amo.browse(self._context['active_ids'])
if len(moves) == 1 and moves.move_type not in ('out_invoice', 'in_invoice'):
res['date'] = moves.date + relativedelta(days=1)
entry_moves = moves.filtered(lambda m: m.move_type == "entry")
if entry_moves:
reversed_move = amo.search([('reversed_entry_id', 'in', entry_moves.ids)], limit=1)
if reversed_move:
raise UserError(_(
"Move '%s' has already been reversed by move '%s'.") % (
reversed_move.reversed_entry_id.display_name,
reversed_move.display_name))
reversed_move = amo.search([('reversed_entry_id', 'in', moves.ids)], limit=1)
if reversed_move:
raise UserError(_(
"Move '%s' has already been reversed by move '%s'.") % (
reversed_move.reversed_entry_id.display_name,
reversed_move.display_name))
return res

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,26 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Product Editable Sequence",
"summary": "Make s=the sequence mass editable with a default value of 100",
"version": "14.0.1.0.0",
"development_status": "Alpha",
"category": "Uncategorized",
"website": "www.akretion.com",
"author": " Akretion",
"license": "AGPL-3",
"external_dependencies": {
"python": [],
"bin": [],
},
"depends": [
"product",
],
"data": [
"views/product_template_views.xml",
],
"demo": [
],
}

View File

@@ -0,0 +1,11 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
sequence = fields.Integer(default=100)

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="product_template_view_tree" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view" />
<field name="arch" type="xml">
<field name="sequence" position="attributes">
<attribute name="widget"/>
<attribute name="readonly"/>
</field>
</field>
</record>
</odoo>

View File

@@ -14,7 +14,9 @@ class ProductTemplate(models.Model):
# in v10, that field was defined in procurement_suggest, but we will
# probably not port procurement_suggest because it is native in v14
seller_id = fields.Many2one(
'res.partner', related='seller_ids.name', store=True,
'res.partner',
compute="_compute_seller_id",
search="_search_seller_id",
string='Main Supplier')
# in v14, I noticed that the tracking of the fields of product.template
@@ -33,6 +35,19 @@ class ProductTemplate(models.Model):
company_id = fields.Many2one(tracking=110)
barcode_type = fields.Char(compute='_compute_template_barcode_type')
def _search_seller_id(self, operator, value):
# searching on the first line of a o2m is not that easy
# So we search all potential matching products
# Then we filter on the seller_id
records = self.search([("seller_ids.partner_id", operator, value)])
records = records.filtered_domain([("seller_id", operator, value)])
return [("id", "in", records.ids)]
def _compute_seller_id(self):
for record in self:
record.seller_id = fields.first(record.seller_ids).name
@api.depends('product_variant_ids.barcode')
def _compute_template_barcode_type(self):
ppo = self.env['product.product']

View File

@@ -7,6 +7,7 @@ from . import stock_warehouse_orderpoint
from . import stock_quant
from . import stock_quant_package
from . import stock_inventory
from . import stock_production_lot
from . import procurement_group
from . import procurement_scheduler_log
from . import product

View File

@@ -2,7 +2,7 @@
# @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
from odoo import models
class StockLocation(models.Model):

View File

@@ -0,0 +1,13 @@
# Copyright 2024 Akretion France (https://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
class StockProductionLot(models.Model):
_inherit = 'stock.production.lot'
name = fields.Char(tracking=True)
product_id = fields.Many2one(tracking=True)
ref = fields.Char(tracking=True)

View File

@@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _
from odoo.tools import float_compare, float_is_zero
from odoo.tools import float_compare
from odoo.exceptions import UserError
import logging
logger = logging.getLogger(__name__)