Skip to content

Commit 59260b2

Browse files
author
Ivan Yelizariev
committed
[ADD] Manual Credit Updates
closes #297
1 parent 3f575cb commit 59260b2

File tree

11 files changed

+166
-2
lines changed

11 files changed

+166
-2
lines changed

pos_debt_notebook/__openerp__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'images/screenshot-3.png',
99
'images/screenshot-1.png',
1010
],
11-
'version': '4.2.0',
11+
'version': '4.3.0',
1212

1313
'author': 'IT-Projects LLC, Ivan Yelizariev',
1414
"support": "apps@it-projects.info",
@@ -26,6 +26,7 @@
2626
'data/product.xml',
2727
'views.xml',
2828
'views/pos_debt_report_view.xml',
29+
'views/pos_credit_update.xml',
2930
'data.xml',
3031
'security/ir.model.access.csv',
3132
],

pos_debt_notebook/doc/changelog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
`4.3.0`
2+
-------
3+
4+
- **ADD:** Manual Credit Updates
5+
16
`4.2.0`
27
-------
8+
39
- **ADD:** The "Load More" button in debt history
410
- **ADD:** A product list to each debt history line
511

612
`4.1.0`
713
-------
14+
815
- **ADD:** Invoice support
916
- **FIX:** Fetch new partners before loading their debt history (e.g. when another POS create partner)
1017
- **ADD:** print prev and new debt value in receipt as well as customer name
1118

1219
`4.0.0`
1320
-------
21+
1422
- **ADD:** An ability to show customer debt transactions
1523
- **ADD:** Credits can be purchased via Credit Product. No need to use Debt Journal at that case
1624
- **ADD:** Max Debt setting per each customer. Default is 0.

pos_debt_notebook/models.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,32 @@ def _compute_product_list(self):
281281
for o_line in order.lines:
282282
product_list.append('%s(%s * %s) + ' % (o_line.product_id.name, o_line.qty, o_line.price_unit))
283283
order.product_list = ''.join(product_list).strip(' + ')
284+
285+
286+
class PosCreditUpdate(models.Model):
287+
_name = 'pos.credit.update'
288+
_description = "Manual Credit Updates"
289+
290+
partner_id = fields.Many2one('res.partner', string="Partner", required=True)
291+
user_id = fields.Many2one(
292+
'res.users',
293+
string='Salesperson',
294+
default=lambda s: s.env.user,
295+
readonly=True
296+
)
297+
company_id = fields.Many2one(
298+
'res.company',
299+
string='Company',
300+
required=True,
301+
default=lambda s: s.env.user.company_id,
302+
)
303+
currency_id = fields.Many2one(
304+
'res.currency',
305+
string='Currency',
306+
default=lambda s: s.env.user.company_id.currency_id,
307+
)
308+
balance = fields.Monetary('Balance Update', help="Change of balance. Negative value for purchases without money (debt). Positive for credit payments (prepament or payments for debts).")
309+
note = fields.Text('Note')
310+
date = fields.Datetime(string='Date', default=fields.Date.today, required=True)
311+
312+
state = fields.Selection([('confirm', 'Confirmed'), ('cancel', 'Canceled')], default='confirm', required=True)

pos_debt_notebook/report/pos_debt_report.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class PosDebtReport(models.Model):
1212

1313
order_id = fields.Many2one('pos.order', string='POS Order', readonly=True)
1414
invoice_id = fields.Many2one('account.invoice', string='Invoice', readonly=True)
15+
update_id = fields.Many2one('pos.credit.update', string='Manual Update', readonly=True)
1516

1617
date = fields.Datetime(string='Date', readonly=True)
1718
partner_id = fields.Many2one('res.partner', string='Partner', readonly=True)
@@ -36,6 +37,7 @@ def init(self):
3637
st_line.id as id,
3738
o.id as order_id,
3839
NULL::integer as invoice_id,
40+
NULL::integer as update_id,
3941
-st_line.amount as balance,
4042
st.state as state,
4143
false as credit_product,
@@ -65,6 +67,7 @@ def init(self):
6567
-pos_line.id as id,
6668
o.id as order_id,
6769
NULL::integer as invoice_id,
70+
NULL::integer as update_id,
6871
pos_line.price_unit * qty as balance,
6972
CASE o.state
7073
WHEN 'done' THEN 'confirm'
@@ -101,6 +104,7 @@ def init(self):
101104
(2147483647 - inv_line.id) as id,
102105
NULL::integer as order_id,
103106
inv.id as invoice_id,
107+
NULL::integer as update_id,
104108
inv_line.price_subtotal as balance,
105109
'confirm' as state,
106110
true as credit_product,
@@ -122,5 +126,29 @@ def init(self):
122126
pt.credit_product=true
123127
AND inv.state in ('paid')
124128
)
129+
UNION ALL
130+
(
131+
SELECT
132+
(-2147483647 + record.id) as id,
133+
NULL::integer as order_id,
134+
NULL::integer as invoice_id,
135+
record.id as update_id,
136+
record.balance as balance,
137+
record.state as state,
138+
false as credit_product,
139+
140+
record.date as date,
141+
record.partner_id as partner_id,
142+
record.user_id as user_id,
143+
NULL::integer as session_id,
144+
NULL::integer as config_id,
145+
record.company_id as company_id,
146+
record.currency_id as currency_id,
147+
record.note as product_list
148+
149+
FROM pos_credit_update as record
150+
WHERE
151+
record.state in ('confirm')
152+
)
125153
)
126154
""")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
22
access_report_pos_debt,access_report_pos_debt,model_report_pos_debt,base.group_user,1,1,1,1
3+
access_pos_credit_update,access_pos_credit_update,model_pos_credit_update,point_of_sale.group_pos_user,1,0,0,0
4+
access_pos_credit_update_manager,access_pos_credit_update,model_pos_credit_update,point_of_sale.group_pos_manager,1,1,1,1
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<record id="view_pos_credit_update_tree" model="ir.ui.view">
4+
<field name="name">pos.credit.update.tree</field>
5+
<field name="model">pos.credit.update</field>
6+
<field name="arch" type="xml">
7+
<tree>
8+
<field name="partner_id"/>
9+
<field name="date"/>
10+
<field name="balance"/>
11+
<field name="note"/>
12+
</tree>
13+
</field>
14+
</record>
15+
16+
<record id="view_pos_credit_update_form" model="ir.ui.view">
17+
<field name="name">pos.credit.update.form</field>
18+
<field name="model">pos.credit.update</field>
19+
<field name="arch" type="xml">
20+
<form>
21+
<header>
22+
<field name="state" widget="statusbar" statusbar_visible="confirm,cancel" />
23+
</header>
24+
25+
<sheet>
26+
<group>
27+
<group>
28+
<field name="partner_id"/>
29+
<field name="date"/>
30+
<field name="balance"/>
31+
<field name="currency_id"/>
32+
<field name="company_id" groups="base.group_multi_company"/>
33+
<field name="note"/>
34+
</group>
35+
</group>
36+
</sheet>
37+
</form>
38+
</field>
39+
</record>
40+
41+
<record id="view_pos_credit_update_search" model="ir.ui.view">
42+
<field name="name">pos.credit.update.search</field>
43+
<field name="model">pos.credit.update</field>
44+
<field name="arch" type="xml">
45+
<search>
46+
<field name="date"/>
47+
<filter string="This Year" name="year" domain="[('date','&lt;=', time.strftime('%%Y-12-31')),('date','&gt;=',time.strftime('%%Y-01-01'))]" help="POS ordered created during current year"/>
48+
<filter string="Today" name="today" domain="[('date', '&gt;=', datetime.datetime.combine(context_today(), datetime.time(0,0,0))), ('date', '&lt;=', datetime.datetime.combine(context_today(), datetime.time(23,59,59)))]"/>
49+
<separator/>
50+
<field name="partner_id"/>
51+
<field name="user_id"/>
52+
<group expand="1" string="Group By">
53+
<filter string="Salesperson" name="User" context="{'group_by':'user_id'}"/>
54+
<filter string="Customer" context="{'group_by':'partner_id'}"/>
55+
<separator/>
56+
<filter string="Month" context="{'group_by':'date:month'}"/>
57+
<filter string="Week" context="{'group_by':'date:week'}"/>
58+
<filter string="Day" context="{'group_by':'date:day'}"/>
59+
<filter string="Hour" context="{'group_by':'date:hour'}"/>
60+
</group>
61+
</search>
62+
</field>
63+
</record>
64+
65+
<record id="action_pos_credit_update" model="ir.actions.act_window">
66+
<field name="name">Manual Credit Updates</field>
67+
<field name="res_model">pos.credit.update</field>
68+
<field name="view_type">form</field>
69+
<field name="view_mode">tree,form</field>
70+
<field name="search_view_id" ref="view_pos_credit_update_search"/>
71+
<field name="context">{}</field>
72+
</record>
73+
74+
75+
<menuitem id="menu_pos_credit_update" name="Manual Credit Updates" action="action_pos_credit_update" parent="point_of_sale.menu_point_config_product" groups="point_of_sale.group_pos_manager" sequence="100"/>
76+
</odoo>

pos_debt_notebook/views/pos_debt_report_view.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<group>
4646
<field name="order_id"/>
4747
<field name="invoice_id"/>
48+
<field name="update_id"/>
4849
<field name="credit_product"/>
4950
<field name="state"/>
5051

pos_debt_notebook_sync/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"summary": """Credit payment system for festivals, food courts, etc.""",
55
"category": "Point of Sale",
66
"images": ['images/credit.png'],
7-
"version": "1.0.0",
7+
"version": "1.1.0",
88
"application": False,
99

1010
"author": "IT-Projects LLC, Dinar Gabbasov",

pos_debt_notebook_sync/data/base_action_rule.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,15 @@
6262
<field name="server_action_ids" eval="[(6,0,[ref('action_notify_pos_about_debt_updates')])]"/>
6363
</record>
6464

65+
<!-- manual credit updates -->
66+
<record id="rule_pos_credit_updates" model="base.action.rule">
67+
<field name="name">Notify POS about Debt updates (on addins Manual Credit Updates).</field>
68+
<field name="model_id" ref="pos_debt_notebook.model_pos_credit_update"/>
69+
<field name="kind">on_create_or_write</field>
70+
<field name="act_user_id" ref="base.user_root"/>
71+
<field name="server_action_ids" eval="[(6,0,[ref('action_notify_pos_about_debt_updates')])]"/>
72+
</record>
73+
74+
6575
</data>
6676
</odoo>

pos_debt_notebook_sync/doc/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
`1.1.0`
2+
-------
3+
4+
- **ADD:** Manual Credit Updates
5+
16
`1.0.0`
27
-------
38

0 commit comments

Comments
 (0)