From 1f17fda2104bb9ba8d68b5dc0d72b8aae0b4590b Mon Sep 17 00:00:00 2001 From: "Aung Ko Ko Lin (Quartile)" <45355704+AungKoKoLin1997@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:46:13 +0700 Subject: [PATCH] [4507][ADD] website_sale_default_warehouse (#223) * [ADD] website_sale_default_warehouse --- website_sale_default_warehouse/README.rst | 52 +++ website_sale_default_warehouse/__init__.py | 1 + .../__manifest__.py | 13 + .../models/__init__.py | 2 + .../models/res_company.py | 10 + .../models/website.py | 17 + .../readme/DESCRIPTION.rst | 1 + .../static/description/index.html | 407 ++++++++++++++++++ .../views/res_company_views.xml | 15 + 9 files changed, 518 insertions(+) create mode 100644 website_sale_default_warehouse/README.rst 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/static/description/index.html create mode 100644 website_sale_default_warehouse/views/res_company_views.xml diff --git a/website_sale_default_warehouse/README.rst b/website_sale_default_warehouse/README.rst new file mode 100644 index 00000000..81e174dc --- /dev/null +++ b/website_sale_default_warehouse/README.rst @@ -0,0 +1,52 @@ +============================== +Website Sale Default Warehouse +============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-qrtl%2Fpci--custom-lightgray.png?logo=github + :target: https://github.com/qrtl/pci-custom/tree/10.0/website_sale_default_warehouse + :alt: qrtl/pci-custom + +|badge1| |badge2| |badge3| + +This module sets the default warehouse in a sale order originating from website sales. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Quartile Limited + +Maintainers +~~~~~~~~~~~ + +This module is part of the `qrtl/pci-custom `_ project on GitHub. + +You are welcome to contribute. 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/static/description/index.html b/website_sale_default_warehouse/static/description/index.html new file mode 100644 index 00000000..1f3fc2e9 --- /dev/null +++ b/website_sale_default_warehouse/static/description/index.html @@ -0,0 +1,407 @@ + + + + + + +Website Sale Default Warehouse + + + +
+

Website Sale Default Warehouse

+ + +

Beta License: AGPL-3 qrtl/pci-custom

+

This module sets the default warehouse in a sale order originating from website sales.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Quartile Limited
  • +
+
+
+

Maintainers

+

This module is part of the qrtl/pci-custom project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + 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..50ec4e8e --- /dev/null +++ b/website_sale_default_warehouse/views/res_company_views.xml @@ -0,0 +1,15 @@ + + + + res.company.form + res.company + + + + + + + + + +