diff --git a/website_sale_default_warehouse/__init__.py b/website_sale_default_warehouse/__init__.py new file mode 100644 index 0000000..0650744 --- /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 0000000..2f31a6b --- /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 0000000..f49771d --- /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 0000000..3ade06b --- /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 0000000..bffc512 --- /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 0000000..685de23 --- /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 0000000..9166f79 --- /dev/null +++ b/website_sale_default_warehouse/views/res_company_views.xml @@ -0,0 +1,15 @@ + + + + res.company.form + res.company + + + + + + + + + +