Merge and conflicts Resolving

bzr revid: ruchakpatel@gmail.com-20081027063052-26bu1pruviuhufi9
This commit is contained in:
Rucha Patel
2008-10-27 12:00:52 +05:30
34 changed files with 2221 additions and 1772 deletions
@@ -70,7 +70,7 @@ period_fields = {
},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With Movements'),('bal_solde','With Balance != 0'),('bal_all','All')]},
'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
'date_from': {'string':" Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
+3
View File
@@ -0,0 +1,3 @@
import voucher
import voucher_account
import report
+33
View File
@@ -0,0 +1,33 @@
{
"name" : "India Accounting",
"version" : "1.0",
"author" : "Tiny",
"description": """
India Accounting module includes all the basic requirenment of
Basic Accounting, plus new things which available are
* Indian Account Chart
* New Invoice - (Local, Retail)
* Invoice Report
* Tax structure
* Journals
* VAT Declaration report
* Accounting Periods
""",
"category" : "Generic Modules/Accounting",
"website" : "http://tinyerp.com",
"depends" : ["base", "account"],
"init_xml" : [
],
"demo_xml" : [
],
"update_xml" : [
"account_voucher_sequence.xml",
"account_view.xml",
"account_report.xml",
"voucher_view.xml",
],
"active": False,
"installable": True
}
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<terp>
<data>
<report id="report_account_voucher"
string="Voucher Report (Cr/Dr)"
model="account.voucher"
name="voucher.cash_receipt"
rml="account_voucher/report/report_voucher.rml"
auto="False"
header = "False"
menu="True"/>
<report id="report_account_voucher_amt"
string="Voucher Report"
model="account.voucher"
name="voucher.cash_amount"
rml="account_voucher/report/report_voucher_amount.rml"
auto="False"
header = "False"
menu="True"/>
</data>
</terp>
+57
View File
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="account_form1">
<field name="name">account.form</field>
<field name="inherit_id" ref="account.view_account_form"/>
<field name="model">account.account</field>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_type" position="after">
<field name="diff" select="2" />
<field name="balance" string="Closing Balance" select="2"/>
<field name="type1" select="2" />
<field name="open_bal" select="2"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="account_form2">
<field name="name">account.form</field>
<field name="inherit_id" ref="account.view_account_form"/>
<field name="model">account.account</field>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="user_type" position="replace">
<field name="user_type" select="1" on_change="onchange_type(user_type,type1)"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="account_form3">
<field name="name">account.form</field>
<field name="inherit_id" ref="account.view_account_tree"/>
<field name="model">account.account</field>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="open_bal" select="1"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="account_form4">
<field name="name">account.form</field>
<field name="inherit_id" ref="account.view_account_tree"/>
<field name="model">account.account</field>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="balance" position="replace">
<field name="balance" />
<field name="type1"/>
</field>
</field>
</record>
</data>
</openerp>
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">
<record model="res.request.link" id="req_link_voucher">
<field name="name">Voucher</field>
<field name="object">account.voucher</field>
</record>
<!--
Sequences types for vouchers
-->
<record model="ir.sequence.type" id="seq_type_cash_rec_voucher">
<field name="name">Account Cash Received Voucher</field>
<field name="code">account.voucher.rec_voucher</field>
</record>
<record model="ir.sequence.type" id="seq_type_cash_pay_voucher">
<field name="name">Account Cash Payble Voucher</field>
<field name="code">account.voucher.pay_voucher</field>
</record>
<record model="ir.sequence.type" id="seq_type_bank_rec_voucher">
<field name="name">Account Bank Received Voucher</field>
<field name="code">account.voucher.bank_rec_voucher</field>
</record>
<record model="ir.sequence.type" id="seq_type_bank_pay_voucher">
<field name="name">Account Bank Payble Voucher</field>
<field name="code">account.voucher.bank_pay_voucher</field>
</record>
<record model="ir.sequence.type" id="seq_type_contra_voucher">
<field name="name">Account Contra Voucher</field>
<field name="code">account.voucher.cont_voucher</field>
</record>
<record model="ir.sequence.type" id="seq_type_jou_sale_voucher">
<field name="name">Account Journal Voucher</field>
<field name="code">account.voucher.journal_sale_vou</field>
</record>
<record model="ir.sequence.type" id="seq_type_jou_pur_voucher">
<field name="name">Account Journal Voucher</field>
<field name="code">account.voucher.journal_pur_vou</field>
</record>
<!--
Sequences for vouchers
-->
<record model="ir.sequence" id="seq_cash_rec_voucher">
<field name="name">Account Cash Received Voucher</field>
<field name="code">account.voucher.rec_voucher</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<record model="ir.sequence" id="seq_cash_pay_voucher">
<field name="name">Account Cash Payble Voucher</field>
<field name="code">account.voucher.pay_voucher</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<record model="ir.sequence" id="seq_bank_rec_voucher">
<field name="name">Account Bank Received Voucher</field>
<field name="code">account.voucher.bank_rec_voucher</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<record model="ir.sequence" id="seq_bank_pay_voucher">
<field name="name">Account Bank Payble Voucher</field>
<field name="code">account.voucher.bank_pay_voucher</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<record model="ir.sequence" id="seq_contra_voucher">
<field name="name">Account Contra Voucher</field>
<field name="code">account.voucher.cont_voucher</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<record model="ir.sequence" id="seq_jou_sale_voucher">
<field name="name">Account Journal Voucher</field>
<field name="code">account.voucher.journal_sale_vou</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<record model="ir.sequence" id="seq_jou_pur_voucher">
<field name="name">Account Journal Voucher</field>
<field name="code">account.voucher.journal_pur_vou</field>
<field name="padding" eval="3"/>
<field name="prefix">%(year)s/</field>
</record>
<!--
Sequences types for analytic account
<record model="ir.sequence.type" id="seq_type_analytic_account">
<field name="name">Analytic account</field>
<field name="code">account.analytic.account</field>
</record>
Sequence for analytic account
<record model="ir.sequence" id="seq_analytic_account">
<field name="name">Analytic account sequence</field>
<field name="code">account.analytic.account</field>
<field name="padding" eval="3" />
<field name="number_next" eval="2708" />
</record>
-->
</data>
</openerp>
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<terp>
<data>
<wizard
id="wizard_account_voucher_open"
menu="False"
model="account.voucher"
name="account.voucher.open"
string="Open a Voucher Entry"
/>
<menuitem
action="wizard_account_voucher_open"
id="menu_wizard_account_voucher_open"
name="Financial Management/Voucher Entries/Open Vouchers"
sequence="0"
type="wizard"
/>
</data>
</terp>
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<terp>
<data>
<record id="wkf_voucher" model="workflow">
<field name="name">account.voucher.basic</field>
<field name="osv">account.voucher</field>
<field name="on_create">True</field>
</record>
<record id="act_draft" model="workflow.activity">
<field name="wkf_id" ref="wkf_voucher"/>
<field name="flow_start">True</field>
<field name="name">draft</field>
</record>
<record id="act_performa" model="workflow.activity">
<field name="wkf_id" ref="wkf_voucher"/>
<field name="name">performa</field>
<field name="action">open_voucher()</field>
<field name="kind">function</field>
</record>
<record id="act_posted" model="workflow.activity">
<field name="wkf_id" ref="wkf_voucher"/>
<field name="name">posted</field>
<field name="action">proforma_voucher()</field>
<field name="flow_stop">True</field>
<field name="kind">function</field>
</record>
<record id="act_cancel" model="workflow.activity">
<field name="wkf_id" ref="wkf_voucher"/>
<field name="name">cancel</field>
<field name="action">cancel_voucher()</field>
<field name="kind">function</field>
</record>
<record id="t1" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_performa"/>
<field name="signal">open_voucher</field>
</record>
<record id="t2" model="workflow.transition">
<field name="act_from" ref="act_performa"/>
<field name="act_to" ref="act_posted"/>
<field name="signal">proforma_voucher</field>
</record>
<record id="t3" model="workflow.transition">
<field name="act_from" ref="act_performa"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">cancel_voucher</field>
</record>
<record id="t5" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">cancel_voucher</field>
</record>
<record id="t6" model="workflow.transition">
<field name="act_from" ref="act_posted"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">cancel_voucher</field>
</record>
<record id="t7" model="workflow.transition">
<field name="act_from" ref="act_cancel"/>
<field name="act_to" ref="act_performa"/>
<field name="signal">open_voucher</field>
</record>
</data>
</terp>
+2
View File
@@ -0,0 +1,2 @@
import report_voucher
import report_voucher_amount
+72
View File
@@ -0,0 +1,72 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
from report import report_sxw
from tools import amount_to_text_en
class report_voucher(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(report_voucher, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'convert':self.convert,
'debit':self.debit,
'credit':self.credit,
'get_ref' : self._get_ref
})
def convert(self,amount, cur):
amt_en = amount_to_text_en.amount_to_text(amount,'en',cur);
return amt_en
def debit(self, move_ids):
debit = 0.0
for move in move_ids:#self.pool.get('account.move.line').browse(self.cr, self.uid, move_ids):
debit +=move.debit
return debit
def credit(self, move_ids):
credit = 0.0
for move in move_ids:#self.pool.get('account.move.line').browse(self.cr, self.uid, move_ids):
credit +=move.credit
return credit
def _get_ref(self, voucher_id, move_ids):
voucher_line = self.pool.get('account.voucher.line').search(self.cr, self.uid, [('partner_id','=',move_ids.partner_id.id), ('voucher_id','=',voucher_id)])
if voucher_line:
voucher = self.pool.get('account.voucher.line').browse(self.cr, self.uid, voucher_line)[0]
return voucher.ref
else:
return
report_sxw.report_sxw(
'report.voucher.cash_receipt',
'account.voucher',
'addons/account_voucher/report/report_voucher.rml',
parser=report_voucher,header=False
)
+381
View File
@@ -0,0 +1,381 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Heading1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
</blockTableStyle>
<blockTableStyle id="voucher_lines">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="last_info">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,7" stop="0,7"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,7" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,7" stop="1,7"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,7" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,7" stop="2,7"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT"/>
<paraStyle name="P2" fontName="Helvetica-Bold" fontSize="13.0" leading="16" alignment="CENTER"/>
<paraStyle name="P3" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Helvetica-Bold" fontSize="22.0" leading="27" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P6" fontName="Helvetica" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P7" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P8" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P9" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P10" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P11" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P14" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P15" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P16" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P17" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P18" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P19" fontName="Helvetica" fontSize="5.0" leading="7" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P20" fontName="Helvetica" fontSize="5.0" leading="7" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P21" fontName="Helvetica" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P22" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P23" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P24" fontName="Helvetica-Bold" fontSize="13.0" leading="16" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P25" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P26" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P27" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P28" rightIndent="0.0" leftIndent="15.0" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P30" rightIndent="0.0" leftIndent="20.0" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P31" rightIndent="0.0" leftIndent="25.0" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Standard" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="Text body" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Italic" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT"/>
<paraStyle name="Table Contents" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
</stylesheet>
<images/>
<story>
<para style="P26">[[ repeatIn(objects,'voucher') ]]</para>
<para style="P4">[[ company.name ]]</para>
<para style="P6">[[ company.partner_id.address and company.partner_id.address[0].street ]]</para>
<para style="P6">[[ company.partner_id.address and company.partner_id.address[0].zip ]] [[ company.partner_id.address and company.partner_id.address[0].city ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name ]]</para>
<para style="P6">[[ company.partner_id.address and company.partner_id.address[0].phone ]]</para>
<para style="P6">[[ company.partner_id.address and company.partner_id.address[0].email ]]</para>
<para style="P5">
<font color="white"> </font>
</para>
<para style="P24">Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]]</para>
<para style="P2">Cash Payment Voucher [[ (voucher.type == 'pay_voucher' or removeParentNode('para')) and '' ]]</para>
<para style="P24">Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]]</para>
<para style="P2">Bank Payment Voucher [[ (voucher.type == 'bank_pay_voucher' or removeParentNode('para')) and '' ]]</para>
<para style="P23">
<font color="white"> </font>
</para>
<blockTable colWidths="49.0,143.0,116.0,69.0,106.0" style="Table1">
<tr>
<td>
<para style="P10">No.</para>
</td>
<td>
<para style="P27">[[ voucher.number ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P10">Dated :</para>
</td>
<td>
<para style="P27">[[ time.strftime('%d %B,%Y', time.strptime(voucher.date , '%Y-%m-%d')) or '' ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P10">State :</para>
</td>
<td>
<para style="P25">PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]]</para>
<para style="P25">Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]]</para>
<para style="P25">Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]]</para>
<para style="P25">Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P10">Ref. :</para>
</td>
<td>
<para style="P27">[[ voucher.reference ]]</para>
</td>
</tr>
</blockTable>
<para style="P12">
<font color="white"> </font>
</para>
<para style="P12">
<font color="white"> </font>
</para>
<blockTable colWidths="255.0,114.0,114.0" style="Heading1">
<tr>
<td>
<para style="P14">Particulars</para>
</td>
<td>
<para style="P15">Debit</para>
</td>
<td>
<para style="P15">Credit</para>
</td>
</tr>
</blockTable>
<para style="P19"/>
<blockTable colWidths="482.0" style="voucher_lines">
<tr>
<td>
<para style="P20">[[ repeatIn(voucher.move_ids,'move_ids') ]] </para>
<blockTable colWidths="251.0,110.0,115.0" style="Table2">
<tr>
<td>
<para style="P11">[[ (move_ids.partner_id and move_ids.partner_id.name) or '']] :</para>
<para style="P28">[[ move_ids.account_id.name ]] </para>
<para style="P31">[[ get_ref(voucher.id,move_ids) ]]</para>
</td>
<td>
<para style="P21">[[ move_ids.debit ]]</para>
</td>
<td>
<para style="P21">[[ move_ids.credit ]]</para>
</td>
</tr>
</blockTable>
<para style="P22">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="253.0,114.0,114.0" style="last_info">
<tr>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P13">Through : </para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P30">[[ voucher.narration or '']]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P13">On Account of : </para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P30">[[ voucher.name ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P13">Amount (in words) : </para>
</td>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P30">[[ convert(voucher.amount,voucher.currency_id.name) ]]</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P16">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P17">[[ debit(voucher.move_ids)]]</para>
</td>
<td>
<para style="P17">[[ credit(voucher.move_ids) ]]</para>
</td>
</tr>
</blockTable>
<para style="P18">
<font color="white"> </font>
</para>
<blockTable colWidths="142.0,99.0,105.0,136.0" style="Table3">
<tr>
<td>
<para style="P7">
<font color="white"> </font>
</para>
<para style="P7">
<font color="white"> </font>
</para>
<para style="P7">
<font color="white"> </font>
</para>
<para style="P7">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P7">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P23">Receiver's Signature</para>
</td>
<td>
<para style="P23">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P23">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P23">Authorised Signatory</para>
</td>
</tr>
</blockTable>
<para style="P1">
<font color="white"> </font>
</para>
</story>
</document>
@@ -1,9 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -30,15 +27,25 @@
import time
from report import report_sxw
from osv import osv
from tools import amount_to_text_en
class order(report_sxw.rml_parse):
class report_voucher_amount(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(order, self).__init__(cr, uid, name, context)
super(report_voucher_amount, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'convert':self.convert
})
report_sxw.report_sxw('report.repair.order','mrp.repair','addons/mrp_repair/report/order.rml',parser=order)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
def convert(self,amount, cur):
amt_en = amount_to_text_en.amount_to_text(amount,'en',cur);
return amt_en
report_sxw.report_sxw(
'report.voucher.cash_amount',
'account.voucher',
'addons/account_voucher/report/report_voucher_amount.rml',
parser=report_voucher_amount,header=False
)
+353
View File
@@ -0,0 +1,353 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Heading1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
</blockTableStyle>
<blockTableStyle id="voucher_lines">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="last_info">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,7" stop="0,7"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,7" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,7" stop="1,7"/>
<lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT"/>
<paraStyle name="P2" fontName="Helvetica-Bold" fontSize="13.0" leading="16" alignment="CENTER"/>
<paraStyle name="P3" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Helvetica-Bold" fontSize="22.0" leading="27" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P6" fontName="Helvetica" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P7" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P8" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P9" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P10" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P11" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P14" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P15" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P16" fontName="Helvetica" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P17" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P18" fontName="Helvetica" fontSize="5.0" leading="7" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P19" fontName="Helvetica" fontSize="5.0" leading="7" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P20" fontName="Helvetica" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P21" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P22" fontName="Helvetica" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P23" fontName="Helvetica-Bold" fontSize="13.0" leading="16" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P24" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P25" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P26" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P27" rightIndent="0.0" leftIndent="15.0" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P29" rightIndent="0.0" leftIndent="20.0" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P30" rightIndent="0.0" leftIndent="25.0" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Standard" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="Text body" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Italic" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT"/>
<paraStyle name="Table Contents" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
</stylesheet>
<images/>
<story>
<para style="P25">[[ repeatIn(objects,'voucher') ]]</para>
<para style="P4">[[ company.name ]]</para>
<para style="P6">[[ company.partner_id.address and company.partner_id.address[0].street ]]</para>
<para style="P6">[[ company.partner_id.address and company.partner_id.address[0].zip ]] [[ company.partner_id.address and company.partner_id.address[0].city ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name ]]</para>
<para style="P6">[[ company.partner_id.address and company.partner_id.address[0].phone ]]</para>
<para style="P6">[[ company.partner_id.address and company.partner_id.address[0].email ]]</para>
<para style="P5">
<font color="white"> </font>
</para>
<para style="P23">Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]]</para>
<para style="P2">Cash Payment Voucher [[ (voucher.type == 'pay_voucher' or removeParentNode('para')) and '' ]]</para>
<para style="P23">Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]]</para>
<para style="P2">Bank Payment Voucher [[ (voucher.type == 'bank_pay_voucher' or removeParentNode('para')) and '' ]]</para>
<para style="P22">
<font color="white"> </font>
</para>
<blockTable colWidths="68.0,124.0,122.0,62.0,106.0" style="Table1">
<tr>
<td>
<para style="P10">No.</para>
</td>
<td>
<para style="P26">[[ voucher.number ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P10">Dated :</para>
</td>
<td>
<para style="P26">[[ time.strftime('%d %B,%Y', time.strptime(voucher.date , '%Y-%m-%d')) or '' ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P10">State :</para>
</td>
<td>
<para style="P24">PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]]</para>
<para style="P24">Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]]</para>
<para style="P24">Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]]</para>
<para style="P24">Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P10">Ref. :</para>
</td>
<td>
<para style="P26">[[ voucher.reference ]]</para>
</td>
</tr>
<tr>
<td>
<para style="P10">Account :</para>
</td>
<td>
<para style="P24">[[ voucher.account_id.name ]]</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P10">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P26">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P12"/>
<para style="P12">
<font color="white"> </font>
</para>
<blockTable colWidths="333.0,149.0" style="Heading1">
<tr>
<td>
<para style="P14">Particulars</para>
</td>
<td>
<para style="P15">Amount</para>
</td>
</tr>
</blockTable>
<para style="P18">
<font color="white"> </font>
</para>
<blockTable colWidths="482.0" style="voucher_lines">
<tr>
<td>
<para style="P19">[[ repeatIn(voucher.payment_ids,'payment_ids') ]] </para>
<blockTable colWidths="324.0,152.0" style="Table6">
<tr>
<td>
<para style="P11">[[ payment_ids.partner_id.name ]] :</para>
<para style="P27">[[ payment_ids.account_id.name ]] </para>
<para style="P30">[[ payment_ids.ref ]] [[ payment_ids.amount ]] [[ payment_ids.type ]]</para>
</td>
<td>
<para style="P20">[[ payment_ids.amount ]]</para>
</td>
</tr>
</blockTable>
<para style="P21">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="344.0,138.0" style="last_info">
<tr>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P13">Through : </para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P29">[[ voucher.narration or '' ]] </para>
</td>
<td>
<para style="P26">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P13">On Account of : </para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P29">[[ voucher.name ]]</para>
</td>
<td>
<para style="P26">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P13">Amount (in words) : </para>
</td>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P29">[[ convert(voucher.amount,voucher.currency_id.name) ]]</para>
</td>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P12">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P16">[[ voucher.amount ]]</para>
</td>
</tr>
</blockTable>
<para style="P17">
<font color="white"> </font>
</para>
<blockTable colWidths="142.0,99.0,105.0,136.0" style="Table5">
<tr>
<td>
<para style="P7">
<font color="white"> </font>
</para>
<para style="P7">
<font color="white"> </font>
</para>
<para style="P7">
<font color="white"> </font>
</para>
<para style="P7">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P7">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P8">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P9">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P22">Receiver's Signature</para>
</td>
<td>
<para style="P22">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P22">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P22">Authorised Signatory</para>
</td>
</tr>
</blockTable>
<para style="P1">
<font color="white"> </font>
</para>
</story>
</document>
+537
View File
@@ -0,0 +1,537 @@
import time
import netsvc
from osv import fields, osv
import ir
import pooler
import mx.DateTime
from mx.DateTime import RelativeDateTime
from tools import config
class account_voucher(osv.osv):
def _get_period(self, cr, uid, context):
periods = self.pool.get('account.period').find(cr, uid)
if periods:
return periods[0]
else:
return False
def _get_type(self, cr, uid, context={}):
type = context.get('type', 'rec_voucher')
return type
def _get_reference_type(self, cursor, user, context=None):
return [('none', 'Free Reference')]
def _get_journal(self, cr, uid, context):
type_inv = context.get('type', 'rec_voucher')
type2journal = {'rec_voucher': 'cash', 'bank_rec_voucher': 'cash','pay_voucher': 'cash','bank_pay_voucher': 'cash', 'cont_voucher': 'cash','journal_sale_voucher': 'sale','journal_pur_voucher': 'purchase' }
journal_obj = self.pool.get('account.journal')
res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'cash'))], limit=1)
if res:
return res[0]
else:
return False
def _get_currency(self, cr, uid, context):
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, [uid])[0]
if user.company_id:
return user.company_id.currency_id.id
else:
return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
_name = 'account.voucher'
_description = 'Accounting Voucher'
_order = "number"
_columns = {
'name':fields.char('Name', size=256, required=True, readonly=True, states={'draft':[('readonly',False)]}),
'type': fields.selection([
('pay_voucher','Cash Payment Voucher'),
('bank_pay_voucher','Bank Payment Voucher'),
('rec_voucher','Cash Receipt Voucher'),
('bank_rec_voucher','Bank Receipt Voucher'),
('cont_voucher','Contra Voucher'),
('journal_sale_vou','Journal Sale Voucher'),
('journal_pur_voucher','Journal Purchase Voucher'),
],'Type', readonly=True, select=True),
'date':fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}),
'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'payment_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=False, states={'proforma':[('readonly',True)]}),
'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}),
'narration':fields.text('Narration', readonly=True, states={'draft':[('readonly',False)]}),
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'company_id': fields.many2one('res.company', 'Company', required=True),
'state':fields.selection(
[('draft','Draft'),
('proforma','Pro-forma'),
('posted','Posted'),
('cancel','Cancel')
], 'State',
readonly=True),
'amount':fields.float('Amount', readonly=True),
# , states={'draft':[('readonly',False)]}
'number':fields.char('Number', size=32, readonly=True),
'reference': fields.char('Voucher Reference', size=64),
'reference_type': fields.selection(_get_reference_type, 'Reference Type',
required=True),
'move_id':fields.many2one('account.move', 'Account Entry'),
'move_ids':fields.many2many('account.move.line', 'voucher_id', 'account_id', 'rel_account_move', 'Real Entry'),
}
# def get_bank(self, cr, uid, context={}):
# type = context.get('type', 'bank_payment')
# journal = self.pool.get('account.journal')
# if type == 'bank_payment':
# id = journal.search(cr, uid, [('name','ilike','Bank')])
# return id
# elif type == 'cash_payment':
# id = journal.search(cr, uid, [('name','ilike','Cash')])
# return id
#
# return 3
_defaults = {
#'journal_id':get_bank,
'state': lambda *a: 'draft',
'date' : lambda *a: time.strftime('%Y-%m-%d'),
'period_id': _get_period,
'type': _get_type,
'reference_type': lambda *a: 'none',
'journal_id':_get_journal,
'company_id': lambda self, cr, uid, context: \
self.pool.get('res.users').browse(cr, uid, uid,
context=context).company_id.id,
'currency_id': _get_currency,
}
def _get_analityc_lines(self, cr, uid, id):
inv = self.browse(cr, uid, [id])[0]
cur_obj = self.pool.get('res.currency')
def onchange_account(self, cr, uid, ids, account_id):
if not account_id:
return {'value':{'amount':False}}
account = self.pool.get('account.account').browse(cr,uid,account_id)
balance=account.balance
return {'value':{'amount':balance}}
def onchange_journal(self, cr, uid, ids, journal_id,type):
if not journal_id:
return {'value':{'account_id':False}}
journal = self.pool.get('account.journal')
if journal_id and (type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher')):
account_id = journal.browse(cr, uid, journal_id).default_debit_account_id
return {'value':{'account_id':account_id.id}}
elif journal_id and (type in ('pay_voucher','bank_pay_voucher','journal_sale_vou')) :
account_id = journal.browse(cr, uid, journal_id).default_credit_account_id
return {'value':{'account_id':account_id.id}}
else:
account_id = journal.browse(cr, uid, journal_id).default_credit_account_id
return {'value':{'account_id':account_id.id}}
def open_voucher(self, cr, uid, ids, context={}):
obj=self.pool.get('account.voucher').browse(cr,uid,ids)
total=0
for i in obj[0].payment_ids:
total+=i.amount
self.write(cr,uid,ids,{'amount':total})
self.write(cr, uid, ids, {'state':'proforma'})
return True
def proforma_voucher(self, cr, uid, ids, context={}):
self.action_move_line_create(cr, uid, ids)
self.action_number(cr, uid, ids)
self.write(cr, uid, ids, {'state':'posted'})
return True
def cancel_voucher(self,cr,uid,ids,context={}):
self.action_cancel(cr, uid, ids)
self.write(cr, uid, ids, {'state':'cancel'})
return True
def action_cancel_draft(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {'state':'draft'})
return True
def unlink(self, cr, uid, ids):
vouchers = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for t in vouchers:
if t['state'] in ('draft', 'cancel'):
unlink_ids.append(t['id'])
else:
raise osv.except_osv('Invalid action !', 'Cannot delete invoice(s) which are already opened or paid !')
osv.osv.unlink(self, cr, uid, unlink_ids)
return True
def _get_analityc_lines(self, cr, uid, id):
inv = self.browse(cr, uid, [id])[0]
cur_obj = self.pool.get('res.currency')
company_currency = inv.company_id.currency_id.id
if inv.type in ('rec_voucher'):
sign = 1
else:
sign = -1
iml = self.pool.get('account.voucher.line').move_line_get(cr, uid, inv.id)
for il in iml:
if il['account_analytic_id']:
if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'):
ref = inv.reference
else:
ref = self._convert_ref(cr, uid, inv.number)
il['analytic_lines'] = [(0,0, {
'name': il['name'],
'date': inv['date'],
'account_id': il['account_analytic_id'],
'amount': inv['amount'] * sign,
'partner_id': il['partner_id'] or False,
'general_account_id': il['account_id'] or False,
'journal_id': self._get_journal(cr, uid, inv.type),
'ref': ref,
})]
return iml
def action_move_line_create(self, cr, uid, ids, *args):
for inv in self.browse(cr, uid, ids):
if inv.move_id:
continue
company_currency = inv.company_id.currency_id.id
# create the analytical lines
line_ids = self.read(cr, uid, [inv.id], ['payment_ids'])[0]['payment_ids']
ils = self.pool.get('account.voucher.line').read(cr, uid, line_ids)
# one move line per invoice line
iml = self._get_analityc_lines(cr, uid, inv.id)
# check if taxes are all computed
diff_currency_p = inv.currency_id.id <> company_currency
# create one move line for the total and possibly adjust the other lines amount
total = 0
if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'):
ref = inv.reference
else:
ref = self._convert_ref(cr, uid, inv.number)
date = inv.date
total_currency = 0
for i in iml:
if inv.currency_id.id != company_currency:
i['currency_id'] = inv.currency_id.id
i['amount_currency'] = i['amount']
else:
i['amount_currency'] = False
i['currency_id'] = False
i['ref'] = ref
if inv.type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher'):
total += i['amount']
total_currency += i['amount_currency'] or i['amount']
i['amount'] = - i['amount']
else:
total -= i['amount']
total_currency -= i['amount_currency'] or i['amount']
acc_id = inv.account_id.id
name = inv['name'] or '/'
totlines = False
iml.append({
'type': 'dest',
'name': name,
'amount': total,
'account_id': acc_id,
'amount_currency': diff_currency_p \
and total_currency or False,
'currency_id': diff_currency_p \
and inv.currency_id.id or False,
'ref': ref
})
date = inv.date
inv.amount=total
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x,date, context={})) ,iml)
journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']})
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
if journal.sequence_id:
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
move = {'name': name, 'line_id': line, 'journal_id': journal_id}
if inv.period_id:
move['period_id'] = inv.period_id.id
for i in line:
i[2]['period_id'] = inv.period_id.id
move_id = self.pool.get('account.move').create(cr, uid, move)
# make the invoice point to that move
self.write(cr, uid, [inv.id], {'move_id': move_id})
obj=self.pool.get('account.move').browse(cr,uid,move_id)
for line in obj.line_id :
cr.execute('insert into voucher_id (account_id,rel_account_move) values (%d, %d)',(int(ids[0]),int(line.id)))
# self.pool.get('account.move').post(cr, uid, [move_id])
# self._log_event(cr, uid, ids)
return True
def line_get_convert(self, cr, uid, x, date, context={}):
return {
'date':date,
'date_maturity': x.get('date_maturity', False),
'partner_id':x.get('partner_id',False),
'name':x['name'][:64],
'debit':x['amount']>0 and x['amount'],
'credit':x['amount']<0 and -x['amount'],
'account_id':x['account_id'],
'analytic_lines':x.get('analytic_lines', []),
'amount_currency':x.get('amount_currency', False),
'currency_id':x.get('currency_id', False),
'tax_code_id': x.get('tax_code_id', False),
'tax_amount': x.get('tax_amount', False),
'ref':x.get('ref',False)
}
def _convert_ref(self, cr, uid, ref):
return (ref or '').replace('/','')
def action_number(self, cr, uid, ids, *args):
cr.execute('SELECT id, type, number, move_id, reference ' \
'FROM account_voucher ' \
'WHERE id IN ('+','.join(map(str,ids))+')')
for (id, invtype, number, move_id, reference) in cr.fetchall():
if not number:
number = self.pool.get('ir.sequence').get(cr, uid,
'account.voucher.' + invtype)
if type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'):
ref = reference
else:
ref = self._convert_ref(cr, uid, number)
cr.execute('UPDATE account_voucher SET number=%s ' \
'WHERE id=%d', (number, id))
cr.execute('UPDATE account_move_line SET ref=%s ' \
'WHERE move_id=%d AND (ref is null OR ref = \'\')',
(ref, move_id))
cr.execute('UPDATE account_analytic_line SET ref=%s ' \
'FROM account_move_line ' \
'WHERE account_move_line.move_id = %d ' \
'AND account_analytic_line.move_id = account_move_line.id',
(ref, move_id))
return True
def name_get(self, cr, uid, ids, context={}):
if not len(ids):
return []
types = {
'pay_voucher': 'CPV: ',
'rec_voucher': 'CRV: ',
'cont_voucher': 'CV: ',
'bank_pay_voucher': 'BPV: ',
'bank_rec_voucher': 'BRV: ',
'journal_sale_vou': 'JSV: ',
'journal_pur_voucher': 'JPV: ',
}
return [(r['id'], types[r['type']]+(r['number'] or '')+' '+(r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')]
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
if not args:
args=[]
if not context:
context={}
ids = []
if name:
ids = self.search(cr, user, [('number','=',name)]+ args, limit=limit, context=context)
if not ids:
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
return self.name_get(cr, user, ids, context)
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default = default.copy()
default.update({'state':'draft', 'number':False, 'move_id':False, 'move_ids':False})
if 'date' not in default:
default['date'] = time.strftime('%Y-%m-%d')
return super(account_voucher, self).copy(cr, uid, id, default, context)
def action_cancel(self, cr, uid, ids, *args):
account_move_obj = self.pool.get('account.move')
voucher = self.read(cr, uid, ids, ['move_id'])
for i in voucher:
if i['move_id']:
account_move_obj.button_cancel(cr, uid, [i['move_id'][0]])
# delete the move this invoice was pointing to
# Note that the corresponding move_lines and move_reconciles
# will be automatically deleted too
account_move_obj.unlink(cr, uid, [i['move_id'][0]])
self.write(cr, uid, ids, {'state':'cancel', 'move_id':False})
# self._log_event(cr, uid, ids,-1.0, 'Cancel Invoice')
return True
account_voucher()
class VoucherLine(osv.osv):
_name = 'account.voucher.line'
_description = 'Voucher Line'
_columns = {
'voucher_id':fields.many2one('account.voucher', 'Voucher'),
'name':fields.char('Description', size=256, required=True),
'account_id':fields.many2one('account.account','Account', required=True),
'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, required=True, ),
'amount':fields.float('Amount'),
'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Type'),
'ref':fields.char('Ref.', size=32),
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account')
}
_defaults = {
'type': lambda *a: 'cr'
}
def move_line_get(self, cr, uid, voucher_id, context={}):
res = []
cur_obj = self.pool.get('res.currency')
inv = self.pool.get('account.voucher').browse(cr, uid, voucher_id)
company_currency = inv.company_id.currency_id.id
cur = inv.currency_id
for line in inv.payment_ids:
res.append(self.move_line_get_item(cr, uid, line, context))
return res
def onchange_partner(self, cr, uid, ids, partner_id, type,type1):
if not partner_id:
return {'value' : {'account_id' : False, 'type' : False ,'amount':False}}
obj = self.pool.get('res.partner')
account_id = False
if type1 in ('rec_voucher','bank_rec_voucher'):
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
balance=obj.browse(cr,uid,partner_id).credit
type = 'cr'
elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') :
account_id = obj.browse(cr, uid, partner_id).property_account_payable
balance=obj.browse(cr,uid,partner_id).debit
type = 'dr'
elif type1 in ('journal_sale_vou') :
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
balance=obj.browse(cr,uid,partner_id).credit
type = 'dr'
elif type1 in ('journal_pur_vou') :
account_id = obj.browse(cr, uid, partner_id).property_account_payable
balance=obj.browse(cr,uid,partner_id).debit
type = 'cr'
return {
'value' : {'account_id' : account_id.id, 'type' : type, 'amount':balance}
}
def onchange_amount(self, cr, uid, ids,partner_id,amount, type,type1):
if not amount:
return {'value' : {'type' : False}}
obj = self.pool.get('res.partner')
if type1 in ('rec_voucher','bank_rec_voucher'):
if amount < 0 :
account_id = obj.browse(cr, uid, partner_id).property_account_payable
type = 'dr'
else:
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
type = 'cr'
elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') :
if amount < 0 :
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
type = 'cr'
else:
account_id = obj.browse(cr, uid, partner_id).property_account_payable
type = 'dr'
elif type1 in ('journal_sale_vou') :
if amount < 0 :
account_id = obj.browse(cr, uid, partner_id).property_account_payable
type = 'cr'
else:
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
type = 'dr'
elif type1 in ('journal_pur_vou') :
if amount< 0 :
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
type = 'dr'
else:
account_id = obj.browse(cr, uid, partner_id).property_account_payable
type = 'cr'
return {
'value' : { 'type' : type , 'amount':amount}
}
def onchange_type(self, cr, uid, ids,partner_id,amount,type,type1):
if not partner_id:
return {'value' : {'type' : False}}
obj = self.pool.get('res.partner')
if type1 in ('rec_voucher','bank_rec_voucher'):
if type == 'dr' :
account_id = obj.browse(cr, uid, partner_id).property_account_payable
total=amount*(-1)
else:
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
total=amount*1
elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') :
if type == 'cr' :
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
amount*=-1
else:
account_id = obj.browse(cr, uid, partner_id).property_account_payable
amount*=1
elif type1 in ('journal_sale_vou') :
if type == 'cr' :
account_id = obj.browse(cr, uid, partner_id).property_account_payable
amount*=-1
else:
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
amount*=1
elif type1 in ('journal_pur_vou') :
if type == 'dr' :
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
amount*=-1
else:
account_id = obj.browse(cr, uid, partner_id).property_account_payable
amount*=1
return {
'value' : {'type' : type , 'amount':total}
}
def move_line_get_item(self, cr, uid, line, context={}):
return {
'type':'src',
'name': line.name[:64],
'amount':line.amount,
'account_id':line.account_id.id,
'partner_id':line.partner_id.id or False ,
'account_analytic_id':line.account_analytic_id.id or False,
}
VoucherLine()
+125
View File
@@ -0,0 +1,125 @@
import time
import netsvc
from osv import fields, osv
import ir
import pooler
import mx.DateTime
from mx.DateTime import RelativeDateTime
from tools import config
class Account(osv.osv):
_inherit = "account.account"
def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''):
#compute the balance/debit/credit accordingly to the value of field_name for the given account ids
mapping = {
'balance': "COALESCE(SUM(l.debit) - SUM(l.credit) , 0) as balance ",
'debit': "COALESCE(SUM(l.debit), 0) as debit ",
'credit': "COALESCE(SUM(l.credit), 0) as credit "
}
#get all the necessary accounts
ids2 = self._get_children_and_consol(cr, uid, ids, context)
acc_set = ",".join(map(str, ids2))
#compute for each account the balance/debit/credit from the move lines
accounts = {}
if ids2:
query = self.pool.get('account.move.line')._query_get(cr, uid,
context=context)
cr.execute(("SELECT l.account_id as id, " +\
' , '.join(map(lambda x: mapping[x], field_names)) +
"FROM " \
"account_move_line l " \
"WHERE " \
"l.account_id IN (%s) " \
"AND " + query + " " \
"GROUP BY l.account_id") % (acc_set, ))
for res in cr.dictfetchall():
accounts[res['id']] = res
#for the asked accounts, get from the dictionnary 'accounts' the value of it
res = {}
for id in ids:
res[id] = self._get_account_values(cr, uid, id, accounts, field_names, context)
for id in ids:
open=self.browse(cr, uid, id, context)
type_id=open.user_type
obj=self.pool.get('account.account.type').browse(cr,uid,type_id.id)
open_balance=open.open_bal
if obj.code in ('cash','asset','expense'):
res[id]['balance']+=open_balance
elif obj.code in ('equity','income','liability'):
total=open_balance*(-1)
res[id]['balance']+=total
else:
res[id]=res[id]
return res
def _get_account_values(self, cr, uid, id, accounts, field_names, context={}):
res = {}.fromkeys(field_names, 0.0)
browse_rec = self.browse(cr, uid, id)
if browse_rec.type == 'consolidation':
ids2 = self.read(cr, uid, [browse_rec.id], ['child_consol_ids'], context)[0]['child_consol_ids']
for t in self.search(cr, uid, [('parent_id', 'child_of', [browse_rec.id])]):
if t not in ids2 and t != browse_rec.id:
ids2.append(t)
for i in ids2:
tmp = self._get_account_values(cr, uid, i, accounts, field_names, context)
for a in field_names:
res[a] += tmp[a]
else:
ids2 = self.search(cr, uid, [('parent_id', 'child_of', [browse_rec.id])])
for i in ids2:
for a in field_names:
res[a] += accounts.get(i, {}).get(a, 0.0)
return res
def _diff(self, cr, uid, ids, field_name, arg, context={}):
res={}
dr_total=0.0
cr_total=0.0
difference=0.0
for id in ids:
open=self.browse(cr, uid, id, context)
if open.type1 == 'dr':
dr_total+=open.open_bal
elif open.type1 == 'cr':
cr_total+=open.open_bal
else:
difference=0.0
difference=dr_total-cr_total
for id in ids:
res[id]=difference
return res
_columns = {
'open_bal' : fields.float('Opening Balance',digits=(16,2)),
'diff' : fields.function(_diff, digits=(16,2),method=True,string='Difference of Opening Bal.'),
'type1':fields.selection([('dr','Debit'),('cr','Credit'),('none','None')], 'Dr/Cr',store=True),
'balance': fields.function(__compute, digits=(16,2), method=True, string='Closing Balance', multi='balance'),
'credit': fields.function(__compute, digits=(16,2), method=True, string='Credit', multi='balance'),
'debit': fields.function(__compute, digits=(16,2), method=True, string='Debit', multi='balance'),
}
def onchange_type(self, cr, uid, ids,user_type,type1):
obj=self.pool.get('account.account.type').browse(cr,uid,user_type)
account_type=obj.code
if not account_type:
return {'value' : {}}
if account_type in ('cash','asset','expense'):
type1 = 'dr'
elif account_type in ('equity','income','liability') :
type1 = 'cr'
else:
type1 = 'none'
return {
'value' : {'type1' : type1}
}
Account()
+295
View File
@@ -0,0 +1,295 @@
<?xml version="1.0" encoding="UTF-8"?>
<terp>
<data>
<record model="ir.ui.view" id="view_voucher_tree">
<field name="name">account.voucher.tree</field>
<field name="model">account.voucher</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Vouchers">
<field name="name"/>
<field name="journal_id"/>
<field name="account_id" />
<field name="amount"/>
<field name="date"/>
<field name="period_id"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_voucher_form">
<field name="name">account.voucher.form</field>
<field name="model">account.voucher</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Voucher">
<notebook>
<page string="Entry">
<field name="number"/>
<field name="type" select="2" on_change="onchange_journal(journal_id,type)"/>
<field name="name" select="1"/>
<field name="journal_id" select="1" on_change="onchange_journal(journal_id,type)"/>
<field name="account_id" select="2" on_change="onchange_account(account_id)"/>
<field name="amount" select="1" required="1"/>
<newline/>
<field name="payment_ids" colspan="4" nolabel="1">
<tree string="Voucher Lines" editable="top">
<field name="partner_id" on_change="onchange_partner(partner_id,type,parent.type)"/>
<field name="account_id" groups="base.group_system"/>
<field name="name" groups="base.group_system"/>
<field name="ref"/>
<field name="amount"/>
<field name="type"/>
</tree>
</field>
<separator string="Narration" colspan="4"/>
<field name="narration" colspan="4" nolabel="1"/>
<group col="6" colspan="6">
<field name="state"/>
<button name="open_voucher" string="Pro-forma" states="draft" type="object"/>
<button name="proforma_voucher" string="Create" states="proforma" type="object"/>
<button name="cancel_voucher" string="Cancel" states="draft,proforma,posted" type="object"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
</group>
</page>
<page string="Other Info">
<field name="company_id" select="1"/>
<field name="reference_type" select="2" nolabel="1" size="0"/>
<field name="reference" select="1" nolabel="1"/>
<field name="currency_id" select="1" />
<field name="period_id"/>
<field name="date" select="1"/>
<field name="move_ids" colspan="4" nolabel="1" readonly="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_voucher_list">
<field name="name">Vouchers</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
</record>
<menuitem name="Financial Management/Voucher Entries"
id="menu_action_voucher_list" action="action_voucher_list"/>
<!-- Receipt Vouchers -->
<record model="ir.actions.act_window" id="action_receipt_vou_voucher_list">
<field name="name">Receipt Vouchers</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','like','rec_voucher')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Receipt Vouchers"
id="menu_action_receipt_vou_voucher_list" action="action_receipt_vou_voucher_list"/>
<record model="ir.actions.act_window" id="action_receipt_cashreceipt_voucher_list">
<field name="name">Cash Receipt</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','=','rec_voucher')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Receipt Vouchers/Cash Receipts"
id="menu_action_receipt_cashreceipt_voucher_list" action="action_receipt_cashreceipt_voucher_list"/>
<record model="ir.actions.act_window" id="action_draft_cash_rec_voucher_form">
<field name="name">Cash Receipt Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','=','rec_voucher'),('state','=','draft')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Receipt Vouchers/Cash Receipts/Draf Cash Receipt"
id="menu_action_draft_cash_rec_voucher_form" action="action_draft_cash_rec_voucher_form"/>
<record model="ir.actions.act_window" id="action_performa_cash_rec_voucher_form">
<field name="name">Cash Receipt Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','=','rec_voucher'),('state','=','proforma')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Receipt Vouchers/Cash Receipts/Pro-forma Cash Receipt"
id="menu_action_performa_cash_rec_voucher_form" action="action_performa_cash_rec_voucher_form"/>
<record model="ir.actions.act_window" id="action_posted_cash_rec_voucher_form">
<field name="name">Cash Receipt Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','=','rec_voucher'),('state','=','posted')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Receipt Vouchers/Cash Receipts/Posted Cash Receipt"
id="menu_action_posted_cash_rec_voucher_form" action="action_posted_cash_rec_voucher_form"/>
<record model="ir.actions.act_window" id="action_cancel_cash_rec_voucher_form">
<field name="name">Cash Receipt Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','=','rec_voucher'),('state','=','cancel')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Receipt Vouchers/Cash Receipts/Cancel Cash Receipt"
id="menu_action_cancel_cash_rec_voucher_form" action="action_cancel_cash_rec_voucher_form"/>
<record model="ir.actions.act_window" id="action_view_cash_rec_voucher_form">
<field name="name">Cash Receipt Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" eval="view_voucher_form"/>
<field name="domain">[('type','=','rec_voucher')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Receipt Vouchers/Cash Receipts/New Cash Receipt" id="menu_action_view_cash_rec_voucher_form" action="action_view_cash_rec_voucher_form"/>
<record model="ir.actions.act_window" id="action_receipt_bakreceipt_voucher_list">
<field name="name">Bank Receipt</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','=','bank_rec_voucher')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Receipt Vouchers/Bank Receipts"
id="menu_action_receipt_bakreceipt_voucher_list" action="action_receipt_bakreceipt_voucher_list"/>
<record model="ir.actions.act_window" id="action_view_bank_rec_voucher_form">
<field name="name">Bank Receipt Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" eval="view_voucher_form"/>
<field name="domain">[('type','=','bank_rec_voucher')]</field>
<field name="context">{'type':'bank_rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Receipt Vouchers/Bank Receipts/New Bank Receipt" id="menu_action_view_bank_rec_voucher_form" action="action_view_bank_rec_voucher_form"/>
<!-- End Receipt Vouchers -->
<!-- Payment Vouchers -->
<record model="ir.actions.act_window" id="action_payments_voucher_list">
<field name="name">Payment Vouchers</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','like','pay_voucher')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Payment Vouchers"
id="menu_action_payments_voucher_list" action="action_payments_voucher_list"/>
<record model="ir.actions.act_window" id="action_payments_cashpay_voucher_list">
<field name="name">Payment Vouchers</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','=','pay_voucher')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Payment Vouchers/Cash Payments"
id="menu_action_payments_cashpay_voucher_list" action="action_payments_cashpay_voucher_list"/>
<record model="ir.actions.act_window" id="action_view_cash_pay_voucher_form">
<field name="name">Cash Payment Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" eval="view_voucher_form"/>
<field name="domain">[('type','=','pay_voucher')]</field>
<field name="context">{'type':'pay_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Payment Vouchers/Cash Payments/New Cash Payment" id="menu_action_view_cash_pay_voucher_form" action="action_view_cash_pay_voucher_form"/>
<record model="ir.actions.act_window" id="action_payments_bankpay_voucher_list">
<field name="name">Payment Vouchers</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
<field name="domain">[('type','=','bank_pay_voucher')]</field>
<field name="context">{'type':'rec_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Payment Vouchers/Bank Payments"
id="menu_action_payments_bankpay_voucher_list" action="action_payments_bankpay_voucher_list"/>
<record model="ir.actions.act_window" id="action_view_bank_pay_voucher_form">
<field name="name">Bank Payment Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" eval="view_voucher_form"/>
<field name="domain">[('type','=','bank_pay_voucher')]</field>
<field name="context">{'type':'bank_pay_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Payment Vouchers/Bank Payments/New Bank Payment" id="menu_action_view_bank_pay_voucher_form" action="action_view_bank_pay_voucher_form"/>
<!-- End Payment Vouchers -->
<!-- Other Voucher Enries -->
<record model="ir.actions.act_window" id="action_other_voucher_list">
<field name="name">Other Vouchers</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_voucher_tree"/>
</record>
<menuitem name="Financial Management/Voucher Entries/Other Vouchers"
id="menu_action_other_voucher_list" action="action_other_voucher_list"/>
<record model="ir.actions.act_window" id="action_view_cont_voucher_form">
<field name="name">Contra Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" eval="view_voucher_form"/>
<field name="domain">[('type','=','cont_voucher')]</field>
<field name="context">{'type':'cont_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Other Vouchers/Contra Voucher" id="menu_action_view_cont_voucher_form" action="action_view_cont_voucher_form"/>
<record model="ir.actions.act_window" id="action_view_jour_sale_voucher_form">
<field name="name">Journal Sale Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" eval="view_voucher_form"/>
<field name="domain">[('type','=','journal_sale_voucher')]</field>
<field name="context">{'type':'journal_sale_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Other Vouchers/Journal Sale Voucher" id="menu_action_view_jour_sale_voucher_form" action="action_view_jour_sale_voucher_form"/>
<record model="ir.actions.act_window" id="action_view_jour_pur_voucher_form">
<field name="name">Journal Purchase Voucher</field>
<field name="res_model">account.voucher</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" eval="view_voucher_form"/>
<field name="domain">[('type','=','journal_pur_voucher')]</field>
<field name="context">{'type':'journal_pur_voucher'}</field>
</record>
<menuitem name="Financial Management/Voucher Entries/Other Vouchers/Journal Purchase Voucher" id="menu_action_view_jour_pur_voucher_form" action="action_view_jour_pur_voucher_form"/>
</data>
</terp>
@@ -0,0 +1 @@
import open_voucher
@@ -0,0 +1,113 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
from tools.translate import _
import pooler
_voucher_form = '''<?xml version="1.0"?>
<form string="Open Vouchers">
<field name="type"/>
<field name="state"/>
<field name="period_ids" colspan="4"/>
</form>'''
_types = {
'pay_voucher':'Cash Payment Voucher',
'bank_pay_voucher':'Bank Payment Voucher',
'rec_voucher':'Cash Receipt Voucher',
'bank_rec_voucher':'Bank Receipt Voucher',
'cont_voucher':'Contra Voucher',
'journal_sale_voucher':'Journal Sale Voucher',
'journal_pur_voucher':'Journal Purchase Voucher'
}
_states = {
'draft':'Draft',
'proforma':'Pro-forma',
'posted':'Posted',
'cancel':'Cancel'
}
_voucher_fields = {
'type': {'string':'Voucher Type', 'type':'selection', 'selection':[
('pay_voucher','Cash Payment Voucher'),
('bank_pay_voucher','Bank Payment Voucher'),
('rec_voucher','Cash Receipt Voucher'),
('bank_rec_voucher','Bank Receipt Voucher'),
('cont_voucher','Contra Voucher'),
('journal_sale_voucher','Journal Sale Voucher'),
('journal_pur_voucher','Journal Purchase Voucher')], 'required':True},
'state': {'string':'State', 'type':'selection', 'selection':[
('draft','Draft'),
('proforma','Pro-forma'),
('posted','Posted'),
('cancel','Cancel')], 'required':True},
'period_ids': {'string':'Periods', 'type':'many2many', 'relation':'account.period'},
}
def _action_open_window(self, cr, uid, data, context):
form = data['form']
periods = []
if not form['period_ids'][0][2]:
pool = pooler.get_pool(cr.dbname)
period = pool.get('account.period')
year = pool.get('account.fiscalyear')
year = year.find(cr, uid)
periods = period.search(cr, uid, [('fiscalyear_id','=',year)])
else:
periods = form['period_ids'][0][2]
return {
'domain': "[('type','=','%s'), ('state','=','%s'), ('period_id','in',%s)]" % (form['type'], form['state'], periods),
'name': "%s - %s" % (_types[form['type']], _states[form['state']]),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.voucher',
'view_id': False,
'context': "{'type':'%s', 'state':'%s', 'period_id':%s}" % (form['type'], form['state'], periods),
'type': 'ir.actions.act_window'
}
class OpenVoucherEntries(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':_voucher_form, 'fields':_voucher_fields, 'state':[('end','Cancel'),('open','Open Voucher Entries')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state':'end'}
}
}
OpenVoucherEntries('account.voucher.open')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1
View File
@@ -7015,6 +7015,7 @@
<field name="type">receivable</field>
<field name="user_type" ref="account_type_receivable"/>
<field eval="True" name="reconcile"/>
<field ref="pcg_411000" name="parent_id"/>
</record>
<!--<record id="account.property_account_receivable" model="ir.property">
-36
View File
@@ -1,36 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import mrp_repair
import wizard
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-61
View File
@@ -1,61 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
###############################################################################
# -*- encoding: utf-8 -*-
{
"name":"Products Repairs Module",
"version":"1.0",
"author":"Tiny",
"description": """
The aim is to have a complete module to manage all products repairs. The following topics
should be covered by this module:
Add/remove products in the reparation
Impact for stocks
Invoicing (products and/or services)
Warrenty concept
Repair quotation report
Notes for the technician and for the final customer
(Link to Cases) (option)
""",
"category":"Custom",
"depends":["sale","account"],
"demo_xml":[],
"update_xml":["mrp_repair_view.xml", "mrp_repair_workflow.xml", "mrp_repair_wizard.xml","mrp_repair_report.xml"],
"active": False,
"installable": True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-457
View File
@@ -1,457 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
from osv import fields,osv
import netsvc
import mx.DateTime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
class mrp_repair(osv.osv):
_name = 'mrp.repair'
_description = 'Repairs Order'
_columns = {
'name' : fields.char('Name',size=24),
'product_id': fields.many2one('product.product', string='Product to Repair', required=True ,domain=[('sale_ok','=',True)]),
'partner_id' : fields.many2one('res.partner', 'Partner', select=True),
'address_id': fields.many2one('res.partner.address', 'Delivery Address', domain="[('partner_id','=',partner_id)]"),
'prodlot_id': fields.many2one('stock.production.lot', 'Lot Number', select=True, domain="[('product_id','=',product_id)]"),
'state': fields.selection([
('draft','Quotation'),
('confirmed','Confirmed'),
('2binvoiced','To be Invoiced'),
('done','Done'),
('cancel','Cancel')
], 'State', readonly=True, help="Gives the state of the Repairs Order"),
'location_id': fields.many2one('stock.location', 'Current Location', required=True, select=True),
'location_dest_id': fields.many2one('stock.location', 'Delivery Location'),
'move_id': fields.many2one('stock.move', 'Move',required=True,domain="[('product_id','=',product_id)]"),#,('location_dest_id','=',location_id),('prodlot_id','=',prodlot_id)
'guarantee_limit': fields.date('Guarantee limit'),
'operations' : fields.one2many('mrp.repair.lines', 'repair_id', 'Operation Lines', readonly=True, states={'draft':[('readonly',False)]}),
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist'),
'partner_invoice_id':fields.many2one('res.partner.address', 'Invoice to', readonly=True, states={'draft':[('readonly',False)]}, domain="[('partner_id','=',partner_id)]"),
'invoice_method':fields.selection([
("none","No Invoice"),
("b4repair","Before Repair"),
("after_repair","After Repair")
], "Invoice Method",
select=True),
'invoice_id': fields.many2one('account.invoice', 'Invoice', readonly=True),
'fees_lines' : fields.one2many('mrp.repair.fee', 'repair_id', 'Fees Lines', readonly=True, states={'draft':[('readonly',False)]}),
'internal_notes' : fields.text('Internal Notes'),
'quotation_notes' : fields.text('Quotation Notes'),
}
_defaults = {
'state': lambda *a: 'draft',
'invoice_method': lambda *a: 'none',
'pricelist_id': lambda self, cr, uid,context : self.pool.get('product.pricelist').search(cr,uid,[('type','=','sale')])[0]
}
def onchange_product_id(self, cr, uid, ids, prod_id=False, move_id=False ):
if not prod_id:
return {'value':{'prodlot_id': False , 'move_id': False, 'location_id' : False}}
if move_id:
move = self.pool.get('stock.move').browse(cr, uid, move_id)
product = self.pool.get('product.product').browse(cr, uid, [prod_id])[0]
date = move.date_planned#time.strftime('%Y-%m-%d')
limit = mx.DateTime.strptime(date, '%Y-%m-%d %H:%M:%S') + RelativeDateTime(months=product.warranty, days=-1)
result = {
'guarantee_limit': limit.strftime('%Y-%m-%d'),
}
return { 'value' : result }
return {}
def onchange_partner_id(self, cr, uid, ids, part):
if not part:
return {'value':{'address_id': False ,'partner_invoice_id' : False }}
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery','invoice','default'])
pricelist = self.pool.get('res.partner').property_get(cr, uid,
part,property_pref=['property_product_pricelist']).get('property_product_pricelist',False)
return {'value':{'address_id': addr['delivery'], 'partner_invoice_id' : addr['invoice'] , 'pricelist_id': pricelist}}
def onchange_lot_id(self, cr, uid, ids, lot ):
if not lot:
return {'value':{'location_id': False , 'move_id' : False}}
lot_info = self.pool.get('stock.production.lot').browse(cr, uid, [lot])[0]
move_id = self.pool.get('stock.move').search(cr, uid,[('prodlot_id','=',lot)] )
if move_id:
move = self.pool.get('stock.move').browse(cr, uid, move_id )[0]
# self.onchange_product_id(cr, uid, ids, prod_id, move_id)
return {'value':{'location_id': move.location_dest_id.id , 'move_id': move.id }}
else:
return {'value':{'location_id': False , 'move_id' : False}}
def action_cancel_draft(self, cr, uid, ids, *args):
if not len(ids):
return False
self.write(cr, uid, ids, {'state':'draft'})
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_create(uid, 'mrp.repair', id, cr)
return True
def action_wait(self, cr, uid, ids, *args):
for o in self.browse(cr, uid, ids):
if (o.invoice_method == 'none'):
self.write(cr, uid, [o.id], {'state': 'confirmed'})
elif (o.invoice_method == 'b4repair'):
self.write(cr, uid, [o.id], {'state': '2binvoiced'})
elif (o.invoice_method == 'after_repair'):
self.write(cr, uid, [o.id], {'state': 'confirmed'})
self.pool.get('mrp.repair.lines').write(cr, uid, ids, {'state':'confirmed'})
return True
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed','done']):
res = False
invoices = {}
invoice_ids = []
for o in self.browse(cr,uid,ids):
lines = []
for line in o.operations:
if (line.state in states) and not line.invoiced:
lines.append(line.id)
# created_lines = self.pool.get('sale.order.line').invoice_line_create(cr, uid, lines)
# if created_lines:
# invoices.setdefault(o.partner_id.id, []).append((o, created_lines))
picking_obj=self.pool.get('stock.picking')
for val in invoices.values():
if grouped:
res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x,y: x + y, [l for o,l in val], []))
for o,l in val:
self.write(cr, uid, [o.id], {'state' : 'progress'})
if o.order_policy=='picking':
picking_obj.write(cr,uid,map(lambda x:x.id,o.picking_ids),{'invoice_state':'invoiced'})
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%d,%d)', (o.id, res))
else:
for order, il in val:
res = self._make_invoice(cr, uid, order, il)
invoice_ids.append(res)
self.write(cr, uid, [order.id], {'state' : 'progress'})
if order.order_policy=='picking':
picking_obj.write(cr,uid,map(lambda x:x.id,order.picking_ids),{'invoice_state':'invoiced'})
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%d,%d)', (order.id, res))
return res
def action_ship_create(self, cr, uid, ids, *args):
picking_id=False
company = self.pool.get('res.users').browse(cr, uid, uid).company_id
for repair in self.browse(cr, uid, ids, context={}):
if repair.location_dest_id:
output_id = repair.location_dest_id.id
for line in repair.operations:
proc_id=False
date_planned = time.strftime('%Y-%m-%d %H:%M:%S')
if line.product_id and line.product_id.product_tmpl_id.type in ('product', 'consu'):
location_id = line.location_id.id
if not picking_id:
picking_id = self.pool.get('stock.picking').create(cr, uid, {
'origin': repair.product_id.code, # + (repair.partner_id and repair.partner_id.name) or ' ',
'type': 'out',
'state': 'auto',
'move_type': 'one',
'address_id': repair.address_id.id,
'note': repair.internal_notes,
'invoice_state': 'none',
})
# operation = self.pool.get('stock.move')
# operation.write(cr, uid, line.id,{'picking_id' : picking_id} )
vals = {
'name': line.product_id.name[:64],
'picking_id': picking_id,
'product_id': line.product_id.id,
'date_planned': date_planned,
'product_qty': line.product_uom_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': line.product_uos_qty,
'product_uos': (line.product_uos and line.product_uos.id)\
or line.product_uom.id,
'product_packaging' : line.product_packaging.id,
'address_id': repair.address_id.id,
'location_id': location_id,
'location_dest_id': output_id,
'tracking_id': False,
'state': 'draft',
'note': line.notes,
}
move_id = self.pool.get('stock.move').create(cr, uid, vals)
proc_id = self.pool.get('mrp.procurement').create(cr, uid, {
'name': repair.name or 'Repair',
'origin': repair.name,
'date_planned': date_planned,
'product_id': line.product_id.id,
'product_qty': line.product_uom_qty,
'product_uom': line.product_uom.id,
'location_id': repair.location_id.id,
'procure_method': 'make_to_stock' ,# NEEDS TO BE CHANGED
'move_id': line.id,
})
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
self.pool.get('mrp.repair.lines').write(cr, uid, [line.id], {'procurement_id': proc_id})
elif line.product_id and line.product_id.product_tmpl_id.type=='service':
proc_id = self.pool.get('mrp.procurement').create(cr, uid, {
'name': line.name or 'Repair',
'origin': repair.name,
'date_planned': date_planned,
'product_id': line.product_id.id,
'product_qty': line.product_uom_qty,
'product_uom': line.product_uom.id,
'location_id': repair.location_id.id,
'procure_method': 'make_to_stock' ,# NEEDS TO BE CHANGED
})
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
self.pool.get('mrp.repair.lines').write(cr, uid, [line.id], {'procurement_id': proc_id})
else:
#
# No procurement because no product in the sale.order.line.
#
pass
val = {}
if picking_id:
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
self.write(cr, uid, [repair.id], val)
return True
def procurement_lines_get(self, cr, uid, ids, *args):
res = []
for order in self.browse(cr, uid, ids, context={}):
for line in order.operations:
if line.procurement_id:
res.append(line.procurement_id.id)
return res
def test_state(self, cr, uid, ids, mode, *args):
assert mode in ('finished', 'canceled'), _("invalid mode for test_state")
finished = True
canceled = False
write_done_ids = []
write_cancel_ids = []
for order in self.browse(cr, uid, ids, context={}):
for line in order.operations:
if line.procurement_id and (line.procurement_id.state != 'done') and (line.state!='done'):
finished = False
if line.procurement_id and line.procurement_id.state == 'cancel':
canceled = True
# if a line is finished (ie its procuremnt is done or it has not procuremernt and it
# is not already marked as done, mark it as being so...
if ((not line.procurement_id) or line.procurement_id.state == 'done') and line.state != 'done':
write_done_ids.append(line.id)
# ... same for canceled lines
if line.procurement_id and line.procurement_id.state == 'cancel' and line.state != 'cancel':
write_cancel_ids.append(line.id)
if write_done_ids:
self.pool.get('mrp.repair.lines').write(cr, uid, write_done_ids, {'state': 'done'})
if write_cancel_ids:
self.pool.get('mrp.repair.liness').write(cr, uid, write_cancel_ids, {'state': 'cancel'})
if mode=='finished':
return finished
elif mode=='canceled':
return canceled
def action_ship_end(self, cr, uid, ids, context={}):
for order in self.browse(cr, uid, ids):
val = {}
if (order.invoice_method=='after_repair'):
val['state'] = '2binvoiced'
else:
val['state'] = 'confirmed'
self.write(cr, uid, [order.id], val)
return True
mrp_repair()
class repair_operation(osv.osv):
_name = 'mrp.repair.lines'
_description = 'Repair Operations'
def _get_price(self, cr, uid, ids, name, arg, context={}):
res = {}
for val in self.browse(cr, uid, ids):
if val.repair_id:
current_date = time.strftime('%Y-%m-%d')
if current_date < val.repair_id.guarantee_limit:
res[val.id] = 0.0
if current_date >= val.repair_id.guarantee_limit:
price = 0.0
pricelist = val.repair_id.pricelist_id.id
if pricelist:
price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist], val.product_id.id , 1.0, val.repair_id.partner_id.id)[pricelist]
if price is False:
warning={
'title':'No valid pricelist line found !',
'message':
"Couldn't find a pricelist line matching this product and quantity.\n"
"You have to change either the product, the quantity or the pricelist."
}
else:
res[val.id] = price
return res
def _amount_line_net(self, cr, uid, ids, field_name, arg, context):
res = {}
for line in self.browse(cr, uid, ids):
res[line.id] = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
return res
def _amount_line(self, cr, uid, ids, field_name, arg, context):
res = {}
cur_obj=self.pool.get('res.currency')
for line in self.browse(cr, uid, ids):
res[line.id] = line.price_unit * line.product_uom_qty * (1 - (line.discount or 0.0) / 100.0)
cur = line.repair_id.pricelist_id.currency_id
res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
return res
_columns = {
'name' : fields.char('Name',size=24),
'repair_id': fields.many2one('mrp.repair', 'Repair Order Ref',ondelete='cascade', select=True),
'type': fields.selection([('add','Add'),('remove','Remove')],'Type'),
'invoice': fields.boolean('Invoice'),
'delay': fields.float('Delivery Delay', required=True),
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok','=',True)], required=True),
'invoiced': fields.boolean('Invoiced'),
'procurement_id': fields.many2one('mrp.procurement', 'Procurement'),
'price_unit': fields.function(_get_price, method=True, store= True, type='float', string='Price'),
'price_net': fields.function(_amount_line_net, method=True, string='Net Price'),
'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal'),
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes'),
'property_ids': fields.many2many('mrp.property', 'sale_order_line_property_rel', 'order_id', 'property_id', 'Properties'),
'address_allotment_id' : fields.many2one('res.partner.address', 'Allotment Partner'),
'product_uom_qty': fields.float('Quantity (UoM)', digits=(16,2), required=True),
'product_uom': fields.many2one('product.uom', 'Product UoM', required=True),
'product_uos_qty': fields.float('Quantity (UOS)'),
'product_uos': fields.many2one('product.uom', 'Product UOS'),
'product_packaging': fields.many2one('product.packaging', 'Packaging'),
'move_ids': fields.one2many('stock.move', 'sale_line_id', 'Inventory Moves', readonly=True),
'discount': fields.float('Discount (%)', digits=(16,2)),
'notes': fields.text('Notes'),
'th_weight' : fields.float('Weight'),
'location_id': fields.many2one('stock.location', 'Source Location', required=True, select=True),
'location_dest_id': fields.many2one('stock.location', 'Dest. Location', required=True, select=True),
'state': fields.selection([('draft','Draft'),('confirmed','Confirmed'),('done','Done'),('cancel','Canceled')], 'Status', required=True, readonly=True),
}
def product_id_change(self, cr, uid, ids, pricelist, product, uom=False, product_uom_qty = 0,partner_id=False ):
if not product:
return {'value': {'product_uom_qty' : 0.0, 'product_uom': False},'domain': {'product_uom': []}}
product_obj = self.pool.get('product.product').browse(cr, uid, product)
result = {}
warning = {}
if not uom:
result['product_uom'] = product_obj.uom_id.id
domain = {'product_uom':
[('category_id', '=', product_obj.uom_id.category_id.id)],}
if not pricelist:
warning={
'title':'No Pricelist !',
'message':
'You have to select a pricelist in the Repair form !\n'
'Please set one before choosing a product.'
}
else:
price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist],
product, product_uom_qty or 1.0, partner_id, {
'uom': uom,
})[pricelist]
if price is False:
warning={
'title':'No valid pricelist line found !',
'message':
"Couldn't find a pricelist line matching this product and quantity.\n"
"You have to change either the product, the quantity or the pricelist."
}
else:
result.update({'price_unit': price})
return {'value': result , 'domain' :domain, 'warning':warning}
def onchange_operation_type(self, cr, uid, ids, type ):
if not type:
return {'value':{'location_id': False , 'location_dest_id' : False}}
stock_id = self.pool.get('stock.location').search(cr, uid, [('name','=','Stock')])[0]
produc_id = self.pool.get('stock.location').search(cr, uid, [('name','=','Default Production')])[0]
if type == 'add':
return {'value':{'location_id': stock_id , 'location_dest_id' : produc_id}}
if type == 'remove':
return {'value':{'location_id': produc_id , 'location_dest_id' : stock_id}}
_defaults = {
'name' : lambda *a: 'Repair Operation',
'state': lambda *a: 'draft',
}
repair_operation()
class mrp_repair_fee(osv.osv):
_name = 'mrp.repair.fee'
_description = 'Repair Fees line'
_columns = {
'repair_id': fields.many2one('mrp.repair', 'Repair Order Ref', required=True, ondelete='cascade', select=True),
'name': fields.char('Description', size=8, required=True, select=True),
'product_id': fields.many2one('product.product', 'Product', required=True),
'product_uom_qty': fields.float('Quantity', digits=(16,2), required=True),
'price_unit': fields.float('Unit Price', required=True),
'product_uom': fields.many2one('product.uom', 'Product UoM', required=True),
}
def product_id_change(self, cr, uid, ids, product, uom=False):
if not product:
return {'value': {'product_uom_qty' : 0.0, 'product_uom': False},'domain': {'product_uom': []}}
product_obj = self.pool.get('product.product').browse(cr, uid, product)
result = {}
if not uom:
result['product_uom'] = product_obj.uom_id.id
domain = {'product_uom':
[('category_id', '=', product_obj.uom_id.category_id.id)],}
return {'value': result ,'domain': domain}
mrp_repair_fee()
class stock_move(osv.osv):
_inherit = "stock.move"
_columns = {
'state': fields.selection([('draft','Draft'),('waiting','Waiting'),('confirmed','Confirmed'),('assigned','Assigned'),('done','Done'),('cancel','cancel'),('in_repair','In Repair')], 'Status',),# readonly=True, select=True),
'repair_ids' : fields.one2many('mrp.repair', 'move_id', 'Repairs'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="report_mrp_repair"
string="Repair Quotation"
model="mrp.repair"
name="repair.order"
rml="mrp_repair/report/order.rml"
auto="False"/>
</data>
</openerp>
-183
View File
@@ -1,183 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_repair_order_form" model="ir.ui.view">
<field name="name">mrp.repair.form</field>
<field name="model">mrp.repair</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Repairs order">
<group col="4" colspan="4">
<field name="name"/>
<newline/>
<field name="product_id" select="1" on_change="onchange_product_id(product_id, move_id)"/>
<field name="prodlot_id" select="2" on_change="onchange_lot_id(prodlot_id)"/>
<field name="partner_id" select="2" on_change="onchange_partner_id(partner_id)" />
<field name="address_id"/>
</group>
<notebook colspan="4">
<page string="Products">
<field name="location_id"/>
<field name="move_id" on_change="onchange_product_id(product_id, move_id)"/>
<field name="location_dest_id"/>
<field name="guarantee_limit" />
<newline/>
<separator colspan="4" string="Operations"/>
<field colspan="4" mode="tree,form" name="operations" nolabel="1" widget="one2many_list">
<form string="Operations">
<field name="type" on_change="onchange_operation_type(type)"/>
<field name="invoice"/>
<field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id)"/>
<field name="product_uom_qty" string="Qty"/>
<field name="product_uom" string="UoM"/>
<field name="price_unit"/>
<field name="discount"/>
<field name="price_subtotal"/>
<field name="delay"/>
<field name="location_id"/>
<field name="location_dest_id"/>
<newline/>
<field name="state"/>
</form>
<tree string="Operations lines"> <!-- editable="bottom"> -->
<field name="type" on_change="onchange_operation_type(type)"/>
<field name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_uom,product_uom_qty, parent.partner_id)"/>
<field name="product_uom_qty" string="Qty"/>
<field name="product_uom" string="UoM"/>
<field name="discount"/>
<field name="price_unit"/>
<field name="price_net"/>
<field name="price_subtotal"/>
<field name="invoice"/>
</tree>
</field>
<newline/>
<group col="13" colspan="4">
<field name="state" select="2"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name="action_cancel" states="manual,progress" string="Cancel Order" type="object"/>
<button name="cancel" states="draft" string="Cancel Order"/>
<button name="invoice_cancel" states="invoice_except" string="Cancel Order"/>
<button name="repair_confirm" states="draft" string="Confirm Repair"/>
<button name="invoice_recreate" states="invoice_except" string="Recreate Invoice"/>
<button name="invoice_corrected" states="invoice_except" string="Invoice Corrected"/>
<button name="ship_recreate" states="shipping_except" string="Recreate Procurement"/>
<button name="ship_corrected" states="shipping_except" string="Procurement Corrected"/>
<button name="make_invoice" states="2binvoiced" string="Make Invoice"/>
<button name="ship_cancel" states="shipping_except" string="Cancel Order"/>
<button name="repair_done" states="confirmed" string="Repair Done"/>
<button name="%(action_cancel_repair)d" states="draft,confirmed,2binvoiced" string="Cancel Repair" type="action"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
</group>
</page>
<page string="Invoicing">
<field name="pricelist_id" context="product_id=product_id"/>
<field name="partner_invoice_id"/>
<field name="invoice_method"/>
<field name="invoice_id"/>
<separator colspan="4" string="Fees"/>
<field colspan="4" mode="tree,form" name="fees_lines" nolabel="1" widget="one2many_list">
<form string="Fees Line">
<field name="product_id" on_change="product_id_change(product_id,product_uom)" />
<field name="product_uom_qty" string="Qty"/>
<field name="product_uom" string="UoM" /> <!--on_change="product_id_change(product_id,product_uom)" /> -->
<field name="price_unit"/>
</form>
<tree string="Fees lines"> <!-- editable="bottom"> -->
<field name="product_id"/>
<field name="product_uom_qty" string="Qty"/>
<field name="product_uom" string="UoM"/>
<field name="price_unit"/>
</tree>
</field>
</page>
<page string="Quality">
<separator colspan="4" string="Internal Notes"/>
<field colspan="4" name="internal_notes" nolabel="1"/>
<separator colspan="4" string="Quotation Notes"/>
<field colspan="4" name="quotation_notes" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record id="view_repair_order_tree" model="ir.ui.view">
<field name="name">mrp.repair.tree</field>
<field name="model">mrp.repair</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Repairs order">
<field name="product_id" select="1" />
<field name="prodlot_id" select="2"/>
<field name="partner_id" select="2"/>
<field name="address_id"/>
<field name="location_id"/>
<field name="move_id"/>
<field name="location_dest_id"/>
<field name="guarantee_limit"/>
</tree>
</field>
</record>
<record id="action_repair_order_form" model="ir.actions.act_window">
<field name="name">New Repair</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.repair</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
</record>
<record id="action_repair_order_tree" model="ir.actions.act_window">
<field name="name">Repair Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.repair</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record id="action_repair_quotation_tree" model="ir.actions.act_window">
<field name="name">Repairs in quotation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.repair</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','draft')]</field>
</record>
<record id="action_repair_progress_tree" model="ir.actions.act_window">
<field name="name">Repairs in progress</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.repair</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','confirmed')]</field>
</record>
<record id="action_repair_2binvoiced_tree" model="ir.actions.act_window">
<field name="name">Repairs to be invoiced</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.repair</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','2binvoiced')]</field>
</record>
<menuitem action="action_repair_order_tree" id="menu_repair_order" parent="mrp.menu_mrp_root" name="Repairs"/>
<menuitem action="action_repair_quotation_tree" id="menu_repair_quotation" parent="menu_repair_order"/>
<menuitem action="action_repair_progress_tree" id="menu_repair_progress" parent="menu_repair_order"/>
<menuitem action="action_repair_2binvoiced_tree" id="menu_repair_2binvoiced" parent="menu_repair_order"/>
<menuitem action="action_repair_order_form" id="menu_repair_form" parent="menu_repair_order" sequence = "50"/>
</data>
</openerp>
-22
View File
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard
id="action_cancel_repair"
model="mrp.repair"
name="mrp.repair.cancel"
string="Cancel Repair"
menu = "False"
multi = "True"
/>
<wizard
id="wizard_mrp_repair_make_invoice"
keyword="client_action_multi"
model="mrp.repair"
name="mrp.repair.make_invoice"
multi="True"
string="Make invoices"/>
</data>
</openerp>
-249
View File
@@ -1,249 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="wkf_repair" model="workflow">
<field name="name">mrp.repair.basic</field>
<field name="osv">mrp.repair</field>
<field name="on_create">True</field>
</record>
<!-- Activity -->
<record id="act_draft" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="flow_start">True</field>
<field name="name">draft</field>
</record>
<record id="act_router" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">router</field>
<field name="kind">function</field>
<field name="action">action_wait()</field>
<field name="split_mode">OR</field>
</record>
<record id="act_wait_invoice" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">wait_invoice</field>
</record>
<record id="act_wait_ship" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">wait_ship</field>
</record>
<record id="act_done" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">done</field>
<field name="flow_stop">True</field>
<field name="kind">function</field>
<field name="action">write({'state':'done'})</field>
<field name="join_mode">AND</field>
</record>
<record id="act_cancel" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">cancel</field>
<field name="flow_stop">True</field>
<field name="kind">stopall</field>
<field name="action">action_cancel()</field>
</record>
<record id="act_cancel2" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">cancel2</field>
<field name="flow_stop">True</field>
<field name="kind">stopall</field>
<field name="action">action_cancel()</field>
</record>
<record id="act_cancel3" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">cancel3</field>
<field name="flow_stop">True</field>
<field name="kind">stopall</field>
<field name="action">action_cancel()</field>
</record>
<record id="act_invoice" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">invoice</field>
<field name="kind">subflow</field>
<field name="subflow_id" search="[('name','=','account.invoice.basic')]"/>
<field name="action">action_invoice_create()</field>
</record>
<record id="act_invoice_except" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">invoice_except</field>
<field name="kind">function</field>
<field name="action">action_invoice_cancel()</field>
</record>
<record id="act_invoice_end" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">invoice_end</field>
<field name="kind">dummy</field>
</record>
<record id="act_invoice_cancel" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">invoice_cancel</field>
<field name="flow_stop">True</field>
<field name="kind">stopall</field>
<field name="action">action_cancel()</field>
</record>
<record id="act_ship" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">ship</field>
<field name="kind">function</field>
<field name="action">action_ship_create()</field>
</record>
<record id="act_ship_except" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">ship_except</field>
<field name="kind">function</field>
<field name="action">write({'state':'shipping_except'})</field>
</record>
<record id="act_ship_end" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">ship_end</field>
<field name="kind">function</field>
<field name="action">action_ship_end()</field>
</record>
<record id="act_ship_cancel" model="workflow.activity">
<field name="wkf_id" ref="wkf_repair"/>
<field name="name">ship_cancel</field>
<field name="flow_stop">True</field>
<field name="kind">stopall</field>
<field name="action">action_cancel()</field>
</record>
<!-- Transistion -->
<record id="trans_invoice_end_done" model="workflow.transition">
<field name="act_from" ref="act_invoice_end"/>
<field name="act_to" ref="act_done"/>
</record>
<record id="trans_draft_router" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_router"/>
<field name="signal">repair_confirm</field>
</record>
<record id="trans_draft_cancel" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_cancel"/>
<field name="signal">cancel</field>
</record>
<record id="trans_wait_invoice_all_lines_invoiced" model="workflow.transition">
<field name="act_from" ref="act_wait_invoice"/>
<field name="act_to" ref="act_invoice_end"/>
<field name="signal">all_lines</field>
</record>
<record id="trans_router_wait_invoice_shipping" model="workflow.transition">
<field name="act_from" ref="act_wait_invoice"/>
<field name="act_to" ref="act_invoice_end"/>
<field name="condition">True</field>
</record>
<record id="trans_router_wait_invoice" model="workflow.transition">
<field name="act_from" ref="act_router"/>
<field name="act_to" ref="act_wait_invoice"/>
</record>
<record id="trans_router_wait_ship" model="workflow.transition">
<field name="act_from" ref="act_router"/>
<field name="act_to" ref="act_wait_ship"/>
</record>
<record id="trans_wait_invoice_cancel2" model="workflow.transition">
<field name="act_from" ref="act_wait_invoice"/>
<field name="act_to" ref="act_cancel2"/>
<field name="signal">cancel</field>
</record>
<record id="trans_wait_ship_cancel3" model="workflow.transition">
<field name="act_from" ref="act_wait_ship"/>
<field name="act_to" ref="act_cancel3"/>
<field name="signal">cancel</field>
</record>
<record id="trans_wait_ship_ship" model="workflow.transition">
<field name="act_from" ref="act_wait_ship"/>
<field name="act_to" ref="act_ship"/>
<field name="condition">(invoice_method=='after_repair' or invoice_method=='none')</field>
</record>
<record id="trans_wait_invoice_invoice" model="workflow.transition">
<field name="act_from" ref="act_wait_invoice"/>
<field name="act_to" ref="act_invoice"/>
<field name="condition">(invoice_method=='b4repair')</field>
</record>
<record id="trans_wait_invoice_invoice_manual" model="workflow.transition">
<field name="act_from" ref="act_wait_invoice"/>
<field name="act_to" ref="act_invoice"/>
<field name="signal">make_invoice</field>
</record>
<record id="trans_invoice_invoice_end" model="workflow.transition">
<field name="act_from" ref="act_invoice"/>
<field name="act_to" ref="act_invoice_end"/>
<field name="signal">subflow.paid</field>
</record>
<record id="trans_invoice_invoice_except" model="workflow.transition">
<field name="act_from" ref="act_invoice"/>
<field name="act_to" ref="act_invoice_except"/>
<field name="signal">subflow.cancel</field>
</record>
<record id="trans_invoice_except_invoice" model="workflow.transition">
<field name="act_from" ref="act_invoice_except"/>
<field name="act_to" ref="act_invoice"/>
<field name="signal">invoice_recreate</field>
</record>
<record id="trans_invoice_except_invoice_end" model="workflow.transition">
<field name="act_from" ref="act_invoice_except"/>
<field name="act_to" ref="act_invoice_end"/>
<field name="signal">invoice_corrected</field>
</record>
<record id="trans_invoice_except_invoice_cancel" model="workflow.transition">
<field name="act_from" ref="act_invoice_except"/>
<field name="act_to" ref="act_invoice_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
<record id="trans_ship_end_done" model="workflow.transition">
<field name="act_from" ref="act_ship_end"/>
<field name="act_to" ref="act_done"/>
</record>
<record id="trans_ship_ship_end" model="workflow.transition">
<field name="act_from" ref="act_ship"/>
<field name="act_to" ref="act_ship_end"/>
<field name="trigger_model">mrp.procurement</field>
<field name="trigger_expr_id">procurement_lines_get()</field>
<field name="condition">test_state('finished')</field>
</record>
<record id="trans_ship_ship_except" model="workflow.transition">
<field name="act_from" ref="act_ship"/>
<field name="act_to" ref="act_ship_except"/>
<!--
<field name="trigger_model">mrp.procurement</field>
<field name="trigger_expr_id">procurement_lines_get()</field>
-->
<field name="condition">test_state('canceled')</field>
</record>
<record id="trans_ship_except_ship" model="workflow.transition">
<field name="act_from" ref="act_ship_except"/>
<field name="act_to" ref="act_ship"/>
<field name="signal">ship_recreate</field>
</record>
<record id="trans_ship_except_ship_end" model="workflow.transition">
<field name="act_from" ref="act_ship_except"/>
<field name="act_to" ref="act_ship_end"/>
<field name="signal">ship_corrected</field>
</record>
<record id="trans_ship_except_ship_cancel" model="workflow.transition">
<field name="act_from" ref="act_ship_except"/>
<field name="act_to" ref="act_ship_cancel"/>
<field name="signal">ship_cancel</field>
</record>
</data>
</openerp>
-34
View File
@@ -1,34 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import order
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-236
View File
@@ -1,236 +0,0 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="34.0" y1="42.0" width="527" height="758"/>
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="Standard_Outline">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#000000" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,-1"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,-1"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<blockBackground colorName="#e6e6e6" start="3,0" stop="3,-1"/>
</blockTableStyle>
<blockTableStyle id="Tableau3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau6">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Tableau4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="9.0" leading="11"/>
<paraStyle name="P2" fontName="Times-Roman"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="LEFT"/>
<paraStyle name="P4" fontName="Times-Roman" alignment="LEFT"/>
<paraStyle name="P5" fontName="Times-Bold" fontSize="9.0" leading="11"/>
<paraStyle name="P6" fontName="Times-Bold" fontSize="9.0" leading="11"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT"/>
<paraStyle name="P9" fontName="Times-BoldItalic" fontSize="9.0" leading="11" alignment="LEFT"/>
<paraStyle name="P10" fontName="Times-Italic" fontSize="9.0" leading="11" alignment="LEFT"/>
<paraStyle name="P11" fontName="Times-Bold" fontSize="9.0" leading="11" alignment="RIGHT"/>
<paraStyle name="P12" fontName="Times-Bold" fontSize="9.0" leading="11"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="10.0" leading="13"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="10.0" leading="13"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="4.0" leading="5"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P17" fontName="Times-Roman" fontSize="16.0" leading="20"/>
<paraStyle name="P18" fontName="Times-BoldItalic" fontSize="6.0" leading="8" alignment="LEFT"/>
<paraStyle name="P19" fontName="Times-Roman" fontSize="7.0" leading="9"/>
<paraStyle name="P20" fontName="Times-BoldItalic" fontSize="11.0" leading="14"/>
<paraStyle name="P21" fontName="Times-BoldItalic" fontSize="11.0" leading="14" alignment="CENTER"/>
<paraStyle name="P22" fontName="Times-Roman" fontSize="11.0" leading="14"/>
<paraStyle name="P23" fontName="Times-Roman" fontSize="7.0" leading="9"/>
<paraStyle name="P24" fontName="Times-Bold" fontSize="9.0" leading="11" alignment="RIGHT"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
</stylesheet>
<images/>
<story>
<para style="P1">[[ repeatIn(objects,'o') ]] <font face="Times-Roman">[[ setLang(o.partner_id.lang) ]]</font></para>
<blockTable colWidths="257.0,50.0,220.0" style="Tableau1">
<tr>
<td>
<para style="P5">Shipping address :</para>
<para style="P13">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
<para style="P13">[[ o.address_id.title or '' ]] [[ o.address_id.name ]]</para>
<para style="P13">[[ o.address_id.street ]]</para>
<para style="P13">[[ o.address_id.street2 or '' ]]</para>
<para style="P14"><font face="Times-Roman">[[ o.address_id.zip or '' ]]</font> [[ o.address_id.city or '' ]]</para>
<para style="P14">[[ o.address_id.state_id and o.address_id.state_id.name or '' ]]</para>
<para style="P14">[[ o.address_id.country_id and o.address_id.country_id.name or '' ]]</para>
<para style="P15">
<font color="white"> </font>
</para>
<para style="P6">Invoice address :</para>
<para style="P14">[[ o.address_id.street ]][[ o.address_id.street2 and (', %s' % o.address_id.street2 or '') ]]</para>
<para style="P14">[[ o.address_id.zip or '' ]] [[ o.address_id.city or '' ]] [[ o.address_id.country_id and (', %s' % (o.address_id.country_id and o.address_id.country_id.name or '')) ]]</para>
</td>
<td>
<para style="P16">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P13">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P2">
<font color="white"> </font>
</para>
<para style="P17">[[ o.state&lt;&gt;'draft' and removeParentNode('para') ]] Quotation N° : [[ o.name ]]</para>
<para style="P17">[[ o.state=='draft' and removeParentNode('para') ]] Order N° : [[ o.name ]]</para>
<para style="P17">
<font color="white"> </font>
</para>
<para style="P22">Your order reference : [[ o.client_order_ref or '' ]]</para>
<para style="P22">Date ordered : [[ time.strftime('%d/%m/%Y', time.strptime(o.date_order, '%Y-%m-%d')) ]]</para>
<para style="P22">Our salesman : [[ o.user_id.name ]]</para>
<para style="P2">
<font color="white"> </font>
</para>
<blockTable colWidths="279.0,79.0,87.0,82.0" repeatRows="1" style="Tableau2">
<tr>
<td>
<para style="P20">Product</para>
</td>
<td>
<para style="P21">Quantity</para>
</td>
<td>
<para style="P21">Unit Price</para>
</td>
<td>
<para style="P21">Price</para>
</td>
</tr>
</blockTable>
<section>
<para style="P18">[[ repeatIn(o.operations,'line') ]]</para>
<blockTable colWidths="279.0,79.0,87.0,82.0" style="Tableau3">
<tr>
<td>
<para style="Table Contents">[[ line.product_id.name ]] </para>
</td>
<td>
<para style="Table Contents">[[ line.product_qty ]] [[ line.product_uom.name ]]</para>
</td>
<td>
<para style="Table Contents">[[ line.price_unit ]]</para>
</td>
<td>
<para style="Table Contents">[[ line.price_unit ]]</para>
</td>
</tr>
</blockTable>
</section>
<blockTable colWidths="348.0,69.0,110.0" style="Tableau6">
<tr>
<td>
<para style="P23">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P24">Net Total :</para>
</td>
<td>
<para style="P24">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P23">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P24">Taxes :</para>
</td>
<td>
<para style="P24">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P19">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P11">TOTAL :</para>
</td>
<td>
<para style="P11">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
<para style="P12">
<font color="white"> </font>
</para>
<blockTable colWidths="527.0" style="Tableau4">
<tr>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
</tr>
<tr>
<td>
<para style="P3">[[ format((o.partner_id.property_payment_term and o.partner_id.property_payment_term[1]) or '') ]]</para>
</td>
</tr>
</blockTable>
<para style="P4">
<font color="white"> </font>
</para>
</story>
</document>
-33
View File
@@ -1,33 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard_cancel_repair
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,86 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import netsvc
import pooler
cancel_form = """<?xml version="1.0"?>
<form string="Cancel Repair...??">
<label colspan="4" string="This operation will cancel the Repair process, but not the Invoice or Packing generated.\nDo you want to continue?" />
</form>
"""
cancel_fields = {}
def check_state(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])[0]
if repair_obj.state == 'draft':
pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
return 'end'
else:
return 'display'
def _cancel_repair(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])[0]
pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
return {}
class repair_cancel(wizard.interface):
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'choice', 'next_state' : check_state}
},
'display' : {
'actions' : [],
'result' : {'type' : 'form',
'arch' : cancel_form,
'fields' : cancel_fields,
'state' : [('end', 'No'),('yes', 'Yes') ]}
},
'yes' : {
'actions' : [],
'result' : {'type' : 'action',
'action' : _cancel_repair,
'state' : 'end'}
},
'end' : {
'actions' : [],
'result': {'type': 'state', 'state': 'end'},
},
}
repair_cancel("mrp.repair.cancel")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-34
View File
@@ -1,34 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import sale_delivery
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-43
View File
@@ -1,43 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
###############################################################################
# -*- encoding: utf-8 -*-
{
"name":"Sale Delivery Planning",
"version":"1.0",
"author":"Tiny",
"category":"Custom",
"depends":["sale"],
"demo_xml":[],
"update_xml":["sale_delivery_view.xml"],
"active": False,
"installable": True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-206
View File
@@ -1,206 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import time
from osv import fields,osv
import netsvc
class sale_delivery_line(osv.osv):
_name = 'sale.delivery.line'
def _check_product_qty(self, cr, uid, ids):
for delivery in self.browse(cr, uid, ids):
cr.execute('select sum(product_uom_qty) from sale_order_line where order_id = %d and product_id = %d',(delivery.order_id,delivery.product_id))
sale_product_qty = cr.fetchall()[0][0]
cr.execute('select sum(product_qty) from sale_delivery_line where order_id = %d and product_id = %d',(delivery.order_id,delivery.product_id))
product_qty = cr.fetchall()[0][0]
if sale_product_qty < product_qty:
return False
return True
def _check_products(self, cr, uid, ids):
for delivery in self.browse(cr, uid, ids):
cr.execute('select id from sale_order_line where order_id = %d and product_id = %d',(delivery.order_id,delivery.product_id))
if not len(cr.fetchall()):
return False
return True
_columns = {
'product_id': fields.many2one('product.product', string='Product', required=True ),
'product_qty': fields.float('Product Quantity', digits=(16,2), required=True),
'product_uom' : fields.many2one('product.uom', 'Product UoM', required=True),
'packaging_id' : fields.many2one('product.packaging', 'Packaging'),
'date_planned': fields.datetime('Date Planned', select=True, required=True),
'priority': fields.integer('Priority'),
'note' : fields.text('Note'),
'order_id': fields.many2one('sale.order', 'Order Ref', required=True, ondelete='cascade', select=True),
}
_constraints = [
(_check_products,
'You have selected a product which is not in related Sale Order',
['product_id']),
(_check_product_qty,
'The quanitties plannified in Deliveries must be equals to or less then the quantities in the Sale Order lines',
['product_qty'])]
sale_delivery_line()
class sale_order(osv.osv):
_inherit = 'sale.order'
_columns = {
'delivery_line': fields.one2many('sale.delivery.line', 'order_id', 'Delivery Lines', readonly=True, states={'draft':[('readonly',False)]}),
}
def action_ship_create(self, cr, uid, ids, *args):
# picking_id=False
picking = {}
company = self.pool.get('res.users').browse(cr, uid, uid).company_id
for order in self.browse(cr, uid, ids, context={}):
output_id = order.shop_id.warehouse_id.lot_output_id.id
# picking_id = False
# if not order.delivery_line:
# return super(sale_order, self).action_ship_create(cr, uid, ids)
for line in order.delivery_line:
cr.execute('select id from sale_order_line where order_id = %d and product_id = %d',(ids[0],line.product_id.id))
sale_line_id = cr.fetchall()[0][0]
sale_line = self.pool.get('sale.order.line').browse(cr, uid, sale_line_id)
proc_id=False
date_planned = line.date_planned
# date_planned = (date_planned - DateTime.RelativeDateTime(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
# if line.state == 'done':
# continue
if line.product_id and line.product_id.product_tmpl_id.type in ('product', 'consu'):
location_id = order.shop_id.warehouse_id.lot_stock_id.id
# if not picking_id:
if not date_planned in picking:
loc_dest_id = order.partner_id.property_stock_customer.id
picking_id = self.pool.get('stock.picking').create(cr, uid, {
'origin': order.name,
'type': 'out',
'state': 'confirmed',
'move_type': order.picking_policy,
'sale_id': order.id,
'address_id': order.partner_shipping_id.id,
'note': order.note,
'invoice_state': (order.order_policy=='picking' and '2binvoiced') or 'none',
})
picking[date_planned] = picking_id
else:
picking_id = picking[date_planned]
move_id = self.pool.get('stock.move').create(cr, uid, {
'name': line.product_id.name[:64],
'picking_id': picking_id,
'product_id': line.product_id.id,
'date_planned': date_planned,
'product_qty': line.product_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': line.product_qty,
'product_uos': line.product_uom.id,
'product_packaging' : line.packaging_id.id,
'address_id' : order.partner_shipping_id.id,
'location_id': location_id,
'location_dest_id': output_id,
'tracking_id': False,
'state': 'waiting',
'note': line.note,
})
proc_id = self.pool.get('mrp.procurement').create(cr, uid, {
'name': order.name,
'origin': order.name,
'date_planned': date_planned,
'product_id': line.product_id.id,
'product_qty': line.product_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': line.product_qty,
'product_uos': line.product_uom.id,
'location_id': order.shop_id.warehouse_id.lot_stock_id.id,
'procure_method': sale_line.type,
'move_id': move_id,
'property_ids': [(6, 0, [x.id for x in sale_line.property_ids])],
})
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
# self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
elif line.product_id and line.product_id.product_tmpl_id.type=='service':
proc_id = self.pool.get('mrp.procurement').create(cr, uid, {
'name': line.name,
'origin': order.name,
'date_planned': date_planned,
'product_id': line.product_id.id,
'product_qty': line.product_uom_qty,
'product_uom': line.product_uom.id,
'location_id': order.shop_id.warehouse_id.lot_stock_id.id,
'procure_method': line.type,
'property_ids': [(6, 0, [x.id for x in line.property_ids])],
})
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
# self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
else:
#
# No procurement because no product in the sale.order.line.
#
pass
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', picking['date_planned'], 'button_confirm', cr)
val = {}
# if 'date_planned' in picking and picking['date_planned']:
# print
if order.state=='shipping_except':
val['state'] = 'progress'
if (order.order_policy == 'manual') and order.invoice_ids:
val['state'] = 'manual'
self.write(cr, uid, [order.id], val)
return True
sale_order()
class sale_order_line(osv.osv):
_inherit = 'sale.order.line'
def _get_planned_deliveries(self, cr, uid, ids, field_name, arg, context):
res = {}
for val in self.browse(cr, uid, ids):
cr.execute('select sum(product_qty) from sale_delivery_line where order_id = %d and product_id = %d',(val.order_id,val.product_id))
product_qty = cr.fetchall()[0][0]
res[val.id] = product_qty
return res
_columns = {
'deliveries': fields.function(_get_planned_deliveries, method=True, string='Planned Deliveries'),
}
sale_order_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_sale_delivery_form" model="ir.ui.view">
<field name="name">sale.delivery.form.inherit</field>
<field name="model">sale.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<notebook>
<page string="Deliveries" position="inside">
<field colspan="4" mode="tree,from" name="delivery_line" nolabel="1" widget="one2many_list">
<form string="Delivery Lines">
<field name="product_id"
/>
<field name="product_qty"
/>
<field name="product_uom"
/>
<field name="packaging_id"
/>
<field name="date_planned"/>
<field name="priority"/>
<separator colspan="4" string="Notes"/>
<field name="note" colspan="4" nolabel="1"/>
</form>
<tree string="Delivery Lines">
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="packaging_id"/>
<field name="date_planned"/>
<field name="priority"/>
<field name="note"/>
</tree>
</field>
</page>
</notebook>
</field>
</record>
<record model="ir.ui.view" id="view_order_line_tree_inherited">
<field name="name">sale.order.line.form1</field>
<field name="model">sale.order.line</field>
<field name="type">tree</field>
<field name="inherit_id" ref="sale.view_order_line_tree"/>
<field name="arch" type="xml">
<field name="price_subtotal" position="after">
<field name="deliveries"/>
</field>
</field>
</record>
<record id="view_sale_delivery_form1" model="ir.ui.view">
<field name="name">sale.delivery.form.inherit1</field>
<field name="model">sale.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="price_subtotal" position="after">
<field name="deliveries"/>
</field>
</field>
</record>
</data>
</openerp>