Skip to content

Commit

Permalink
Merge PR #1036 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
OCA-git-bot committed Aug 22, 2023
2 parents 15397e4 + 28baaec commit f5e0cd9
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 0 deletions.
1 change: 1 addition & 0 deletions pos_order_to_sale_order_report/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO :)
1 change: 1 addition & 0 deletions pos_order_to_sale_order_report/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions pos_order_to_sale_order_report/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "PoS Order To Sale Order: Report",
"version": "16.0.1.0.0",
"category": "Sales/Point of Sale",
"summary": "Report will be downloaded after the sales order is created.",
"depends": ["pos_order_to_sale_order"],
"website": "https://github.com/OCA/pos",
"author": "Cetmix,Odoo Community Association (OCA)",
"maintainers": ["GabbasovDinar", "CetmixGitDrone"],
"data": [
"views/res_config_settings_view.xml",
],
"installable": True,
"assets": {
"point_of_sale.assets": [
"pos_order_to_sale_order_report/static/src/js/**/*.js",
],
},
"license": "AGPL-3",
}
2 changes: 2 additions & 0 deletions pos_order_to_sale_order_report/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import pos_config
from . import res_config_settings
20 changes: 20 additions & 0 deletions pos_order_to_sale_order_report/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from odoo import api, fields, models


class PosConfig(models.Model):
_inherit = "pos.config"

@api.model
def _domain_iface_sale_order_report_id(self):
"""
Return domain to select report to print via PoS after create Sale Order
"""
return [
("model", "=", "sale.order"),
("report_type", "=", "qweb-pdf"),
]

iface_sale_order_report_id = fields.Many2one(
"ir.actions.report",
domain=lambda self: self._domain_iface_sale_order_report_id(),
)
14 changes: 14 additions & 0 deletions pos_order_to_sale_order_report/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

pos_iface_sale_order_report_id = fields.Many2one(
"ir.actions.report",
related="pos_config_id.iface_sale_order_report_id",
readonly=False,
)
pos_iface_create_sale_order = fields.Boolean(
related="pos_config_id.iface_create_sale_order",
)
2 changes: 2 additions & 0 deletions pos_order_to_sale_order_report/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Select PoS > Configuration > Settings > Sale Order Creation > specify "Sale Order Report":
.. image:: ../static/img/pos_config.png
2 changes: 2 additions & 0 deletions pos_order_to_sale_order_report/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Dinar Gabbasov <https://github.com/GabbasovDinar>
* Cetmix <https://cetmix.com/>
2 changes: 2 additions & 0 deletions pos_order_to_sale_order_report/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the functionality of the pos_order_to_sale_order module
which allows download a report from Point of Sale after creating a sales order.
1 change: 1 addition & 0 deletions pos_order_to_sale_order_report/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If the report is specified in the pos config then the report will be downloaded automatically when the sales order is created.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/** @odoo-module **/

import CreateOrderPopup from "point_of_sale.CreateOrderPopup";
import Registries from "point_of_sale.Registries";

const PosSaleOrderReportCreateOrderPopup = (CreateOrderPopup) =>
class extends CreateOrderPopup {
async _downloadSaleOrderReport(saleOrderId) {
try {
const report = this.env.pos.config.iface_sale_order_report_id;
if (saleOrderId && report) {
await this.env.legacyActionManager.do_action(report[0], {
additional_context: {
active_ids: [saleOrderId],
},
});
}
} catch (error) {
if (error instanceof Error) {
throw error;
} else {
this.showPopup("ErrorPopup", {
title: this.env._t("Network Error"),
body: this.env._t("Unable to download report."),
});
}
}
}
// @override
async _createSaleOrder(order_state) {
const data = await super._createSaleOrder(order_state);
if (data) {
await this._downloadSaleOrderReport(data.sale_order_id);
}
return data;
}
};

Registries.Component.extend(CreateOrderPopup, PosSaleOrderReportCreateOrderPopup);
35 changes: 35 additions & 0 deletions pos_order_to_sale_order_report/views/res_config_settings_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="view_res_config_settings_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form</field>
<field name="model">res.config.settings</field>
<field
name="inherit_id"
ref="pos_order_to_sale_order.view_res_config_settings_form"
/>
<field name="arch" type="xml">
<xpath
expr="//field[@name='pos_iface_create_invoiced_sale_order']/../.."
position="after"
>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<span class="o_form_label">Report</span>
<div class="text-muted">
This report will be downloaded after the sales order is created.
</div>
<div class="content-group mt16">
<field name="pos_iface_create_sale_order" invisible="1" />
<field
name="pos_iface_sale_order_report_id"
attrs="{'invisible': [('pos_iface_create_sale_order', '=', False)]}"
/>
</div>
</div>
</div>
</xpath>
</field>
</record>

</odoo>
6 changes: 6 additions & 0 deletions setup/pos_order_to_sale_order_report/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit f5e0cd9

Please sign in to comment.