[MIG] purchase_stock_partner_default_picking_type from v14 to v16
This commit is contained in:
1
purchase_stock_partner_default_picking_type/__init__.py
Normal file
1
purchase_stock_partner_default_picking_type/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
24
purchase_stock_partner_default_picking_type/__manifest__.py
Normal file
24
purchase_stock_partner_default_picking_type/__manifest__.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Copyright (C) 2025 Akretion (https://www.akretion.com)
|
||||||
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Purchase Stock Default Picking Type on Partner',
|
||||||
|
'version': '16.0.1.0.0',
|
||||||
|
'category': 'Purchases',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'summary': 'Configure the default picking type for purchase orders on partners',
|
||||||
|
'description': """
|
||||||
|
Purchase Stock Default Picking Type on Partner
|
||||||
|
==============================================
|
||||||
|
|
||||||
|
Allow to configure on partners the default picking type for purchase orders.
|
||||||
|
|
||||||
|
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com> for any help or question about this module.
|
||||||
|
""",
|
||||||
|
'author': 'Akretion',
|
||||||
|
'website': 'https://github.com/akretion/odoo-usability',
|
||||||
|
'depends': ['purchase_stock'],
|
||||||
|
'data': ['views/res_partner.xml'],
|
||||||
|
'installable': True,
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
from . import res_partner
|
||||||
|
from . import purchase_order
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Copyright 2025 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 api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class PurchaseOrder(models.Model):
|
||||||
|
_inherit = "purchase.order"
|
||||||
|
|
||||||
|
# If I set picking_type_id as computed field with store=True and readonly=False
|
||||||
|
# it doesn't work when creating a PO from the smartbutton of the partner form view
|
||||||
|
# in v14 and v16... and I don't understand why :-(
|
||||||
|
# So, until I find the cause of this, I use a good old onchange !
|
||||||
|
@api.onchange("partner_id", "company_id")
|
||||||
|
def onchange_partner_id(self):
|
||||||
|
super().onchange_partner_id()
|
||||||
|
if self.partner_id and self.company_id:
|
||||||
|
partner = self.partner_id.commercial_partner_id.with_company(self.company_id.id)
|
||||||
|
if partner.purchase_picking_type_id:
|
||||||
|
self.picking_type_id = partner.purchase_picking_type_id
|
||||||
|
else:
|
||||||
|
self.picking_type_id = self._get_picking_type(self.company_id.id)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Copyright 2025 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 ResPartner(models.Model):
|
||||||
|
_inherit = 'res.partner'
|
||||||
|
|
||||||
|
# Used only for manual POs
|
||||||
|
purchase_picking_type_id = fields.Many2one(
|
||||||
|
'stock.picking.type', string="Purchase Picking Type",
|
||||||
|
company_dependent=True,
|
||||||
|
domain="[('code', '=', 'incoming'), ('company_id', '=', current_company_id)]")
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2025 Akretion France (https://www.akretion.com/)
|
||||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="view_partner_property_form" model="ir.ui.view">
|
||||||
|
<field name="model">res.partner</field>
|
||||||
|
<field name="inherit_id" ref="purchase.view_partner_property_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="property_purchase_currency_id" position="before">
|
||||||
|
<field name="purchase_picking_type_id" attrs="{'invisible': [('parent_id', '!=', False)]}"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
|
|
||||||
Reference in New Issue
Block a user