Merge lp:~openbig/bigconsulting/sales_shop_stock_availability into lp:bigconsulting

Proposed by gpa(OpenERP)
Status: Merged
Merged at revision: 8
Proposed branch: lp:~openbig/bigconsulting/sales_shop_stock_availability
Merge into: lp:bigconsulting
Diff against target: 764 lines (+707/-0)
11 files modified
account_invoice_cash_discount/__init__.py (+26/-0)
account_invoice_cash_discount/__terp__.py (+45/-0)
account_invoice_cash_discount/account_invoice_cash_discount.py (+195/-0)
account_invoice_cash_discount/account_invoice_cash_discount_view.xml (+47/-0)
account_invoice_cash_discount/account_wizard.xml (+6/-0)
account_invoice_cash_discount/wizard/__init__.py (+26/-0)
account_invoice_cash_discount/wizard/wizard_pay_invoice.py (+203/-0)
sales_shop_stock_availability/__init__.py (+26/-0)
sales_shop_stock_availability/__terp__.py (+38/-0)
sales_shop_stock_availability/sales_shop_stock_availability.py (+52/-0)
sales_shop_stock_availability/sales_shop_stock_availability_view.xml (+43/-0)
To merge this branch: bzr merge lp:~openbig/bigconsulting/sales_shop_stock_availability
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+26274@code.launchpad.net

Description of the change

Added Module sales_shop_stock_avaialbility

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'account_invoice_cash_discount'
=== added file 'account_invoice_cash_discount/__init__.py'
--- account_invoice_cash_discount/__init__.py 1970-01-01 00:00:00 +0000
+++ account_invoice_cash_discount/__init__.py 2010-05-28 07:36:36 +0000
@@ -0,0 +1,26 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import account_invoice_cash_discount
24import wizard
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
26
027
=== added file 'account_invoice_cash_discount/__terp__.py'
--- account_invoice_cash_discount/__terp__.py 1970-01-01 00:00:00 +0000
+++ account_invoice_cash_discount/__terp__.py 2010-05-28 07:36:36 +0000
@@ -0,0 +1,45 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22{
23 "name" : "Payement Term with Cash Discount",
24 "version" : "1.0",
25 "depends" : ["account",],
26 "author" : "Big Consulting",
27 "website" : "",
28 "category" : "",
29 "description": """
30 The Module add automatically account move lines in case of payment with cash discount conditions in reconcilation form.
31 """,
32 "init_xml" : [
33 ],
34 "demo_xml" : [
35 ],
36 "update_xml" : [
37 "account_invoice_cash_discount_view.xml",
38 "account_wizard.xml"
39 ],
40 "active": False,
41 "installable": True,
42
43}
44# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
45
046
=== added file 'account_invoice_cash_discount/account_invoice_cash_discount.py'
--- account_invoice_cash_discount/account_invoice_cash_discount.py 1970-01-01 00:00:00 +0000
+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-05-28 07:36:36 +0000
@@ -0,0 +1,195 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from osv import fields, osv
24from tools import config
25import time
26from mx import DateTime
27
28class account_payment_term(osv.osv):
29 _name = "account.payment.term"
30 _inherit = "account.payment.term"
31 _columns = {
32 'cash_discount_ids': fields.one2many('account.cash.discount', 'payment_id', 'Cash Discounts'),
33 }
34account_payment_term()
35
36class account_cash_discount(osv.osv):
37 _name = "account.cash.discount"
38 _description = "Cash Discount" #A reduction in the price if payment is made within a stipulated period.
39 _columns = {
40 'name': fields.char('Name', size=32),
41 'delay': fields.integer('Number of Days', required=True),
42 'discount': fields.float('Discount (%)', digits=(16,6),required=True),
43 'payment_id': fields.many2one('account.payment.term','Associated Payment Term'),
44 'credit_account_id': fields.many2one('account.account', 'Credit Account'),
45 'debit_account_id': fields.many2one('account.account', 'Debit Account'),
46 }
47account_cash_discount()
48
49class account_invoice(osv.osv):
50 _inherit = "account.invoice"
51
52 def _get_payment(self, cr, uid, ids, resudial_amonut, payment_term, context=None):
53
54 #This function used to count the discount payment term
55 if context is None:
56 context = {}
57
58 tax_obj = self.pool.get('account.tax')
59 invoice = self.browse(cr, uid, ids[0], context=context)
60
61 if invoice.date_due:
62 date1 = invoice.date_due
63 else:
64 date1 = time.strftime('%Y-%m-%d')
65
66 if 'date_p' in context and context['date_p']:
67 date2 = context['date_p']
68 else:
69 date2 = time.strftime('%Y-%m-%d')
70
71 from_dt = time.mktime(time.strptime(date1,'%Y-%m-%d'))
72 to_dt = time.mktime(time.strptime(date2,'%Y-%m-%d'))
73 diff_day = (from_dt-to_dt)/(3600*24)
74 if payment_term:
75 pt = self.pool.get('account.payment.term').browse(cr, uid, payment_term, context=context)
76 if pt.cash_discount_ids:
77 res = 0.0
78 for d in pt.cash_discount_ids:
79 if diff_day == d.delay or diff_day < d.delay:
80 if resudial_amonut:
81 res = resudial_amonut * d.discount
82 ted = 0.0
83 for line in invoice.invoice_line:
84 if line.invoice_line_tax_id:
85 tt = tax_obj.compute_inv(cr, uid, line.invoice_line_tax_id, res, line.quantity)
86 for tex in tt:
87 rr = 0.0
88 rr += tex['amount']
89 ted +=rr
90 discunt = res + ted
91 return discunt
92
93 def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''):
94
95 if context is None:
96 context = {}
97 #TODO check if we can use different period for payment and the writeoff line
98 assert len(ids)==1, "Can only pay one invoice at a time"
99 invoice = self.browse(cr, uid, ids[0])
100
101 if 'amount_currency' in context and context['amount_currency']:
102 amount_currency = context['amount_currency']
103 else:
104 amount_currency = invoice.residual
105
106 if invoice.payment_term:
107 # Return the discount on for the payment term
108 discunt1 = self._get_payment(cr, uid, ids, amount_currency, invoice.payment_term.id, context=context)
109
110 src_account_id = invoice.account_id.id
111 # Take the seq as name for move
112 types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
113 direction = types[invoice.type]
114 #take the choosen date
115 if 'date_p' in context and context['date_p']:
116 date=context['date_p']
117 else:
118 date=time.strftime('%Y-%m-%d')
119
120 # Take the amount in currency and the currency of the payment
121 if 'amount_currency' in context and context['amount_currency'] and 'currency_id' in context and context['currency_id']:
122 amount_currency = context['amount_currency']
123 currency_id = context['currency_id']
124 else:
125 amount_currency = False
126 currency_id = False
127
128 if invoice.type in ('in_invoice', 'in_refund'):
129 ref = invoice.reference
130 else:
131 ref = self._convert_ref(cr, uid, invoice.number)
132 # Pay attention to the sign for both debit/credit AND amount_currency
133 l1 = {
134 'debit': direction * (pay_amount)>0 and direction * (pay_amount),
135 'credit': direction * (pay_amount)<0 and - direction * (pay_amount),
136 'account_id': src_account_id,
137 'partner_id': invoice.partner_id.id,
138 'ref':ref,
139 'date': date,
140 'currency_id':currency_id,
141 'amount_currency':amount_currency and direction * amount_currency or 0.0,
142 }
143 l2 = {
144 'debit': direction * (pay_amount-discunt1)<0 and - direction * (pay_amount-discunt1),
145 'credit': direction * (pay_amount-discunt1)>0 and direction * (pay_amount-discunt1),
146 'account_id': pay_account_id,
147 'partner_id': invoice.partner_id.id,
148 'ref':ref,
149 'date': date,
150 'currency_id':currency_id,
151 'amount_currency':amount_currency and - direction * amount_currency or 0.0,
152 }
153 l3 = {
154 'debit': direction * discunt1<0 and - direction * discunt1,
155 'credit': direction * discunt1>0 and direction * discunt1,
156 'account_id': context['account_id'],
157 'partner_id': invoice.partner_id.id,
158 'ref':ref,
159 'date': date,
160 'currency_id':currency_id,
161 'amount_currency':amount_currency and direction * amount_currency or 0.0,
162 }
163
164 if not name:
165 name = invoice.invoice_line and invoice.invoice_line[0].name or invoice.number
166 l1['name'] = name
167 l2['name'] = name
168 l3['name'] = name
169 lines = [(0, 0, l1), (0, 0, l2), (0, 0, l3)]
170
171 move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
172 move_id = self.pool.get('account.move').create(cr, uid, move, context=context)
173
174 line_ids = []
175 total = 0.0
176 line = self.pool.get('account.move.line')
177 cr.execute('select id from account_move_line where move_id in ('+str(move_id)+','+str(invoice.move_id.id)+')')
178 lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) )
179 for l in lines+invoice.payment_ids:
180 if l.account_id.id==src_account_id:
181 line_ids.append(l.id)
182 total += (l.debit or 0.0) - (l.credit or 0.0)
183 if (not round(total,int(config['price_accuracy']))) or writeoff_acc_id:
184 self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context)
185 else:
186 self.pool.get('account.move.line').reconcile_partial(cr, uid, line_ids, 'manual', context)
187
188 # Update the stored value (fields.function), so we write to trigger recompute
189 self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context)
190 return True
191
192account_invoice()
193
194# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
195
0196
=== added file 'account_invoice_cash_discount/account_invoice_cash_discount_view.xml'
--- account_invoice_cash_discount/account_invoice_cash_discount_view.xml 1970-01-01 00:00:00 +0000
+++ account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-05-28 07:36:36 +0000
@@ -0,0 +1,47 @@
1<?xml version="1.0"?>
2<openerp>
3 <data>
4
5 <!-- cash discount -->
6
7
8 <record model="ir.ui.view" id="view_cash_discount_form">
9 <field name="name">account.cash.discount.form</field>
10 <field name="model">account.cash.discount</field>
11 <field name="type">form</field>
12 <field name="arch" type="xml">
13 <form string="Cash Discount">
14 <field name="name" select="1"/>
15 <field name="delay" select="1"/>
16 <field name="discount" select="1"/>
17 </form>
18 </field>
19 </record>
20
21 <record model="ir.ui.view" id="view_cash_discount_tree">
22 <field name="name">account.cash.discount.tree</field>
23 <field name="model">account.cash.discount</field>
24 <field name="type">tree</field>
25 <field name="arch" type="xml">
26 <tree string="Cash Discount" editable="bottom">
27 <field name="name" select="1"/>
28 <field name="delay" select="1"/>
29 <field name="discount" select="1"/>
30 </tree>
31 </field>
32 </record>
33
34 <record model="ir.ui.view" id="view_payment_term_form">
35 <field name="name">account.payment.term.form</field>
36 <field name="model">account.payment.term</field>
37 <field name="inherit_id" ref="account.view_payment_term_form"/>
38 <field name="arch" type="xml">
39 <field name="line_ids" position="after">
40 <separator string="Cash Discount" colspan="4"/>
41 <field name="cash_discount_ids" colspan="4"/>
42 </field>
43 </field>
44 </record>
45
46 </data>
47</openerp>
048
=== added file 'account_invoice_cash_discount/account_wizard.xml'
--- account_invoice_cash_discount/account_wizard.xml 1970-01-01 00:00:00 +0000
+++ account_invoice_cash_discount/account_wizard.xml 2010-05-28 07:36:36 +0000
@@ -0,0 +1,6 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <wizard id="wizard_invoice_pay" model="account.invoice" name="account.invoice.pay1" string="Pay invoice" groups="base.group_user"/>
5 </data>
6</openerp>
07
=== added directory 'account_invoice_cash_discount/wizard'
=== added file 'account_invoice_cash_discount/wizard/__init__.py'
--- account_invoice_cash_discount/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ account_invoice_cash_discount/wizard/__init__.py 2010-05-28 07:36:36 +0000
@@ -0,0 +1,26 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import wizard_pay_invoice
24
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
26
027
=== added file 'account_invoice_cash_discount/wizard/wizard_pay_invoice.py'
--- account_invoice_cash_discount/wizard/wizard_pay_invoice.py 1970-01-01 00:00:00 +0000
+++ account_invoice_cash_discount/wizard/wizard_pay_invoice.py 2010-05-28 07:36:36 +0000
@@ -0,0 +1,203 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import wizard
24import pooler
25import time
26from tools.translate import _
27import tools
28
29pay_form = '''<?xml version="1.0"?>
30<form string="Pay invoice">
31 <field name="amount"/>
32 <newline/>
33 <field name="name"/>
34 <field name="date"/>
35 <field name="journal_id"/>
36 <field name="period_id"/>
37 <field name="cash_amount"/>
38 <field name="account_id"/>
39</form>'''
40
41pay_fields = {
42 'amount': {'string': 'Amount paid', 'type':'float', 'required':True, 'digits': (16,int(tools.config['price_accuracy']))},
43 'name': {'string': 'Entry Name', 'type':'char', 'size': 64, 'required':True},
44 'cash_amount': {'string': 'Cash Discount Amount', 'type':'float', 'required':True, 'digits': (16,int(tools.config['price_accuracy']))},
45 'account_id': {'string': 'Account For Discount', 'type': 'many2one', 'relation':'account.account', 'required':True},
46 'date': {'string': 'Payment date', 'type':'date', 'required':True, 'default':lambda *args: time.strftime('%Y-%m-%d')},
47 'journal_id': {'string': 'Journal/Payment Mode', 'type': 'many2one', 'relation':'account.journal', 'required':True, 'domain':[('type','=','cash')]},
48 'period_id': {'string': 'Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
49}
50
51def _pay_and_reconcile(self, cr, uid, data, context):
52 form = data['form']
53 period_id = form.get('period_id', False)
54 journal_id = form.get('journal_id', False)
55 writeoff_account_id = form.get('writeoff_acc_id', False)
56 writeoff_journal_id = form.get('writeoff_journal_id', False)
57 pool = pooler.get_pool(cr.dbname)
58 cur_obj = pool.get('res.currency')
59 amount = form['amount']
60 context['analytic_id'] = form.get('analytic_id', False)
61
62 invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
63 journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
64 # Compute the amount in company's currency, with the journal currency (which is equal to payment currency)
65 # when it is needed : If payment currency (according to selected journal.currency) is <> from company currency
66 if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
67 ctx = {'date':data['form']['date']}
68 amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx)
69 currency_id = journal.currency.id
70 # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency
71 context.update({'amount_currency':form['amount'],'currency_id':currency_id})
72
73 if invoice.company_id.currency_id.id<>invoice.currency_id.id:
74 ctx = {'date':data['form']['date']}
75 amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, amount, context=ctx)
76 currency_id = invoice.currency_id.id
77 # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency
78 context.update({'amount_currency':form['amount'],'currency_id':currency_id})
79
80 # Take the choosen date
81 if form.has_key('comment'):
82 context.update({'date_p':form['date'],'comment':form['comment']})
83 else:
84 context.update({'date_p':form['date'],'comment':False})
85
86 context.update({'account_id':form['account_id'],'cash_amount':form['cash_amount'],'amount_currency':form['amount']})
87
88 acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id
89 if not acc_id:
90 raise wizard.except_wizard(_('Error !'), _('Your journal must have a default credit and debit account.'))
91 pool.get('account.invoice').pay_and_reconcile(cr, uid, [data['id']],
92 amount, acc_id, period_id, journal_id, writeoff_account_id,
93 period_id, writeoff_journal_id, context, data['form']['name'])
94 return {}
95
96def _wo_check(self, cr, uid, data, context):
97 pool = pooler.get_pool(cr.dbname)
98 invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
99 journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
100 cur_obj = pool.get('res.currency')
101 # Here we need that:
102 # The invoice total amount in company's currency <> paid amount in company currency
103 # (according to the correct day rate, invoicing rate and payment rate are may be different)
104 # => Ask to a write-off of the difference. This could happen even if both amount are equal,
105 # because if the currency rate
106 # Get the amount in company currency for the invoice (according to move lines)
107 inv_amount_company_currency = 0
108 for aml in invoice.move_id.line_id:
109 if aml.account_id.id == invoice.account_id.id or aml.account_id.type in ('receivable', 'payable'):
110 inv_amount_company_currency += aml.debit
111 inv_amount_company_currency -= aml.credit
112 inv_amount_company_currency = abs(inv_amount_company_currency)
113
114 # Get the current amount paid in company currency
115 if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id:
116 ctx = {'date':data['form']['date']}
117 amount_paid = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, data['form']['amount'], round=True, context=ctx)
118 else:
119 amount_paid = data['form']['amount']
120 # Get the old payment if there are some
121 if invoice.payment_ids:
122 debit=credit=0.0
123 for payment in invoice.payment_ids:
124 debit+=payment.debit
125 credit+=payment.credit
126 amount_paid+=abs(debit-credit)
127
128 # Test if there is a difference according to currency rouding setting
129 if pool.get('res.currency').is_zero(cr, uid, invoice.company_id.currency_id,
130 (amount_paid - inv_amount_company_currency)):
131 return 'reconcile'
132 return 'addendum'
133
134_transaction_add_form = '''<?xml version="1.0"?>
135<form string="Information addendum">
136 <separator string="Write-Off Move" colspan="4"/>
137 <field name="writeoff_journal_id"/>
138 <field name="writeoff_acc_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
139 <field name="comment"/>
140 <separator string="Analytic" colspan="4"/>
141 <field name="analytic_id"/>
142</form>'''
143
144_transaction_add_fields = {
145 'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
146 'writeoff_journal_id': {'string': 'Write-Off journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
147 'comment': {'string': 'Comment', 'type':'char', 'size': 64 , 'required':True},
148 'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
149}
150
151def _get_value_addendum(self, cr, uid, data, context={}):
152 return {'comment': _('Write-Off')}
153
154def _compute(self, cr, uid, data, context={}):
155 pool = pooler.get_pool(cr.dbname)
156 invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
157
158
159def _get_period(self, cr, uid, data, context={}):
160 pool = pooler.get_pool(cr.dbname)
161 ids = pool.get('account.period').find(cr, uid, context=context)
162 period_id = False
163 if len(ids):
164 period_id = ids[0]
165 invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
166 cash_amount = pool.get('account.invoice')._get_payment(cr, uid, [data['id']], invoice.residual, invoice.payment_term.id, context=context)
167 if invoice.state in ['draft', 'proforma2', 'cancel']:
168 raise wizard.except_wizard(_('Error !'), _('Can not pay draft/proforma/cancel invoice.'))
169 return {
170 'period_id': period_id,
171 'amount': invoice.residual,
172 'date': time.strftime('%Y-%m-%d'),
173 'cash_amount': cash_amount,
174 }
175
176class wizard_pay_invoice(wizard.interface):
177 states = {
178 'init': {
179 'actions': [_get_period],
180 'result': {'type':'form', 'arch':pay_form, 'fields':pay_fields, 'state':[('end','Cancel'),('reconcile','Partial Payment'),('writeoff_check','Full Payment')]}
181 },
182 'writeoff_check': {
183 'actions': [],
184 'result' : {'type': 'choice', 'next_state': _wo_check }
185 },
186 'addendum': {
187 'actions': [_get_value_addendum],
188 'result': {'type': 'form', 'arch':_transaction_add_form, 'fields':_transaction_add_fields, 'state':[('end','Cancel'),('reconcile','Pay and reconcile')]}
189 },
190 'reconcile': {
191 'actions': [_pay_and_reconcile],
192 'result': {'type':'state', 'state':'end'}
193 },
194 'compute_dis': {
195 'actions': [_compute],
196 'result': {'type':'state', 'state':'end'}
197 }
198 }
199wizard_pay_invoice('account.invoice.pay1')
200
201
202# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
203
0204
=== added directory 'sales_shop_stock_availability'
=== added file 'sales_shop_stock_availability/__init__.py'
--- sales_shop_stock_availability/__init__.py 1970-01-01 00:00:00 +0000
+++ sales_shop_stock_availability/__init__.py 2010-05-28 07:36:36 +0000
@@ -0,0 +1,26 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import sales_shop_stock_availability
24
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
26
027
=== added file 'sales_shop_stock_availability/__terp__.py'
--- sales_shop_stock_availability/__terp__.py 1970-01-01 00:00:00 +0000
+++ sales_shop_stock_availability/__terp__.py 2010-05-28 07:36:36 +0000
@@ -0,0 +1,38 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22{
23 "name": "Sale Shop Stock Availability",
24 "version": "1.0",
25 "author": "Big Consulting",
26 "website" : "",
27 "category": "",
28 "description": """
29 """,
30 "depends": ['base','sale'],
31 "demo_xml": [],
32 "update_xml": ['sales_shop_stock_availability_view.xml'],
33 "license": "GPL-3",
34 "active": False,
35 "installable": True,
36}
37# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
38
039
=== added file 'sales_shop_stock_availability/sales_shop_stock_availability.py'
--- sales_shop_stock_availability/sales_shop_stock_availability.py 1970-01-01 00:00:00 +0000
+++ sales_shop_stock_availability/sales_shop_stock_availability.py 2010-05-28 07:36:36 +0000
@@ -0,0 +1,52 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# $Id$
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from osv import fields, osv
24from tools import config
25
26class product_product(osv.osv):
27 _inherit = "product.product"
28
29 def _product_available_other_shop(self, cr, uid, ids, name, arg, context={}):
30
31 res = {}
32 product_obj = self.pool.get('product.product')
33 shop = context.get('shop', False)
34 fields_name = ['qty_available']
35
36 stock2 = product_obj._product_available(cr, uid, ids ,fields_name,context={})
37
38 context.update({'shop':shop})
39 stock1 = product_obj._product_available(cr, uid, ids ,fields_name,context=context)
40
41 for key,value in stock2.items():
42 diff = stock2[key]['qty_available'] - stock1[key]['qty_available']
43 res[key] = diff
44 return res
45
46 _columns = {
47 'qty_available_other_shop': fields.function(_product_available_other_shop, method=True, type='float', string='Stock Other Shops', help="Current quantities of products in other stock location except selected shop in sale order."),
48 }
49
50product_product()
51
52# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
053
=== added file 'sales_shop_stock_availability/sales_shop_stock_availability_view.xml'
--- sales_shop_stock_availability/sales_shop_stock_availability_view.xml 1970-01-01 00:00:00 +0000
+++ sales_shop_stock_availability/sales_shop_stock_availability_view.xml 2010-05-28 07:36:36 +0000
@@ -0,0 +1,43 @@
1<?xml version="1.0" ?>
2<openerp>
3 <data>
4
5 <record id="product_stock_tree_view1" model="ir.ui.view">
6 <field name="name">stock.product.tree</field>
7 <field name="model">product.product</field>
8 <field name="type">tree</field>
9 <field eval="7" name="priority"/>
10 <field name="arch" type="xml">
11 <tree colors="red:virtual_available&lt;0;blue:state in ['draft', 'end', 'obsolete']" string="Products">
12 <field name="default_code"/>
13 <field name="name"/>
14 <field name="variants"/>
15 <field name="uom_id"/>
16 <field name="qty_available"/>
17 <field name="virtual_available"/>
18 <field name="qty_available_other_shop"/>
19 <field invisible="'partner_id' not in context" name="price"/>
20 <field name="lst_price"/>
21 <field name="standard_price"/>
22 <field name="state"/>
23 </tree>
24 </field>
25 </record>
26
27 <record id="product_shop_stock_view1" model="ir.ui.view">
28 <field name="name">sale.order.form</field>
29 <field name="model">sale.order</field>
30 <field name="type">form</field>
31 <field name="inherit_id" ref="sale.view_order_form"/>
32 <field name="arch" type="xml">
33 <xpath expr="//field[@name='product_id']" position="replace">
34 <field colspan="4"
35 context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom,tree_view_ref='sales_shop_stock_availability.product_stock_tree_view1'"
36 name="product_id"
37 on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], True, parent.date_order, product_packaging, parent.fiscal_position)"
38 select="1"/>
39 </xpath>
40 </field>
41 </record>
42 </data>
43</openerp>

Subscribers

People subscribed via source and target branches