From 3ed0c42a1650270a6edbede5aea8be639687fc4d Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Mon, 27 May 2024 13:03:26 +0800 Subject: [PATCH] [ADD] website_sale_default_warehouse --- website_sale_default_warehouse/__init__.py | 1 + website_sale_default_warehouse/__manifest__.py | 13 +++++++++++++ .../models/__init__.py | 2 ++ .../models/res_company.py | 10 ++++++++++ .../models/website.py | 17 +++++++++++++++++ .../readme/DESCRIPTION.rst | 1 + .../views/res_company_views.xml | 15 +++++++++++++++ 7 files changed, 59 insertions(+) create mode 100644 website_sale_default_warehouse/__init__.py create mode 100644 website_sale_default_warehouse/__manifest__.py create mode 100644 website_sale_default_warehouse/models/__init__.py create mode 100644 website_sale_default_warehouse/models/res_company.py create mode 100644 website_sale_default_warehouse/models/website.py create mode 100644 website_sale_default_warehouse/readme/DESCRIPTION.rst create mode 100644 website_sale_default_warehouse/views/res_company_views.xml diff --git a/website_sale_default_warehouse/__init__.py b/website_sale_default_warehouse/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/website_sale_default_warehouse/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/website_sale_default_warehouse/__manifest__.py b/website_sale_default_warehouse/__manifest__.py new file mode 100644 index 00000000..2f31a6b9 --- /dev/null +++ b/website_sale_default_warehouse/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Website Sale Default Warehouse", + "version": "10.0.1.0.0", + "category": "Website", + "author": "Quartile Limited", + "license": "AGPL-3", + "website": "https://www.quartile.co", + "depends": ["website_sale_stock",], + "data": ["views/res_company_views.xml"], + "installable": True, +} diff --git a/website_sale_default_warehouse/models/__init__.py b/website_sale_default_warehouse/models/__init__.py new file mode 100644 index 00000000..f49771da --- /dev/null +++ b/website_sale_default_warehouse/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_company +from . import website diff --git a/website_sale_default_warehouse/models/res_company.py b/website_sale_default_warehouse/models/res_company.py new file mode 100644 index 00000000..3ade06b6 --- /dev/null +++ b/website_sale_default_warehouse/models/res_company.py @@ -0,0 +1,10 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = 'res.company' + + default_website_warehouse_id = fields.Many2one("stock.warehouse") diff --git a/website_sale_default_warehouse/models/website.py b/website_sale_default_warehouse/models/website.py new file mode 100644 index 00000000..bffc512f --- /dev/null +++ b/website_sale_default_warehouse/models/website.py @@ -0,0 +1,17 @@ +# Copyright 2024 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class Website(models.Model): + _inherit = 'website' + + @api.multi + def _prepare_sale_order_values(self, partner, pricelist): + values = super(Website, self)._prepare_sale_order_values(partner, pricelist) + if values['company_id']: + warehouse = self.env['res.company'].browse(values['company_id']).default_website_warehouse_id + if warehouse: + values['warehouse_id'] = warehouse.id + return values diff --git a/website_sale_default_warehouse/readme/DESCRIPTION.rst b/website_sale_default_warehouse/readme/DESCRIPTION.rst new file mode 100644 index 00000000..685de239 --- /dev/null +++ b/website_sale_default_warehouse/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module sets the default warehouse in a sale order originating from website sales. diff --git a/website_sale_default_warehouse/views/res_company_views.xml b/website_sale_default_warehouse/views/res_company_views.xml new file mode 100644 index 00000000..9166f79c --- /dev/null +++ b/website_sale_default_warehouse/views/res_company_views.xml @@ -0,0 +1,15 @@ + + + + res.company.form + res.company + + + + + + + + + +