Fonction de facturation

This commit is contained in:
eloyoussef 2018-03-30 17:27:40 +02:00
parent 36058fe141
commit fdf556a8d8
3 changed files with 49 additions and 8 deletions

View File

@ -20,13 +20,13 @@
'name': 'GOLEM resources pack invoicing', 'name': 'GOLEM resources pack invoicing',
'summary': 'GOLEM resources pack invoicing', 'summary': 'GOLEM resources pack invoicing',
'description': ''' GOLEM resources pack invoicing ''', 'description': ''' GOLEM resources pack invoicing ''',
'version': '10.0.0.0.0', 'version': '10.0.0.0.1',
'category': 'GOLEM', 'category': 'GOLEM',
'author': 'Youssef El Ouahby, Fabien Bourgeois', 'author': 'Youssef El Ouahby, Fabien Bourgeois',
'license': 'AGPL-3', 'license': 'AGPL-3',
'application': True, 'application': True,
'installable': True, 'installable': True,
'depends': ['golem_resource_pack', 'account'], 'depends': ['golem_resource_pack', 'golem_resource_account'],
'data': ['views/golem_resource_pack_views.xml'] 'data': ['views/golem_resource_pack_views.xml']
#'security/ir.model.access.csv'] #'security/ir.model.access.csv']
} }

View File

@ -32,13 +32,42 @@ class GolemResourcePack(models.Model):
copy=False) copy=False)
invoice_amount_total = fields.Monetary(related='invoice_id.amount_total') invoice_amount_total = fields.Monetary(related='invoice_id.amount_total')
currency_id = fields.Many2one(related='invoice_id.currency_id') currency_id = fields.Many2one(related='invoice_id.currency_id')
is_products_set = fields.Boolean(compute="compute_is_products_set")
@api.multi
def compute_is_products_set(self):
for pack in self:
product_list = list(map(lambda x: x.resource_product_id, pack.reservation_ids))
if len(filter(lambda x: x.id == False, product_list)) > 0:
pack.is_products_set = False
else:
pack.is_products_set = True
@api.multi @api.multi
def create_invoice(self): def create_invoice(self):
""" create invoice """ """ Invoice creation """
pass for pack in self:
pack.reservation_ids.check_before_invoicing()
inv_obj = self.env['account.invoice']
partner_id = pack.partner_id
invoice_id = inv_obj.create({
'origin': pack.name,
'type': 'out_invoice',
'reference': False,
'account_id': partner_id.property_account_receivable_id.id,
'partner_id': partner_id.id
})
pack.invoice_id = invoice_id.id
pack.reservation_ids.create_invoice_line(invoice_id)
@api.multi @api.multi
def show_invoice(self): def show_invoice(self):
""" show invoice """ """ Redirects to linked invoice """
pass self.ensure_one()
pack = self[0]
if pack.invoice_id:
return {'type': 'ir.actions.act_window',
'res_model': 'account.invoice',
'res_id': pack.invoice_id.id,
'view_mode': 'form',
'view_id': self.env.ref('account.invoice_form').id}

View File

@ -18,21 +18,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<odoo> <odoo>
<data> <data>
<!-- Tree -->
<record model="ir.ui.view" id="golem_resource_pack_inherit_account_tree">
<field name="name">GOLEM Resource Pack Account extention Tree</field>
<field name="model">golem.resource.pack</field>
<field name="inherit_id" ref="golem_resource_pack.golem_resource_pack_view_tree"/>
<field name="arch" type="xml">
<field name="reservation_count" position="after">
<field name="invoice_state" />
</field>
</field>
</record>
<!-- Forms --> <!-- Forms -->
<record model="ir.ui.view" id="golem_resource_pack_inherit_account_form"> <record model="ir.ui.view" id="golem_resource_pack_inherit_account_form">
<field name="name">GOLEM Resource Pack Account extentionForm</field> <field name="name">GOLEM Resource Pack Account extention Form</field>
<field name="model">golem.resource.pack</field> <field name="model">golem.resource.pack</field>
<field name="inherit_id" ref="golem_resource_pack.golem_resource_pack_view_form"/> <field name="inherit_id" ref="golem_resource_pack.golem_resource_pack_view_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<button name="state_rejected" position="after"> <button name="state_rejected" position="after">
<button name="create_invoice" type="object" string="Create Invoice" class="oe_highlight" <button name="create_invoice" type="object" string="Create Invoice" class="oe_highlight"
attrs="{'invisible': ['|', ('state', '!=', 'validated'), ('invoice_id', '!=', False)]}" /> attrs="{'invisible': ['|', ('state', '!=', 'validated'), '|', ('invoice_id', '!=', False), ('is_products_set', '=', False)]}" />
<button name="show_invoice" type="object" string="Show invoice" class="oe_highlight" <button name="show_invoice" type="object" string="Show invoice" class="oe_highlight"
attrs="{'invisible': [('invoice_id', '=', False)]}" /> attrs="{'invisible': [('invoice_id', '=', False)]}" />
</button> </button>
<group name="general" position="after"> <group name="general" position="after">
<group name="invoicing" string="Invoicing" <group name="invoicing" string="Invoicing"
attrs="{'invisible': [('invoice_id', '=', False)]}"> attrs="{'invisible': [('invoice_id', '=', False)]}">
<field name="is_products_set" invisible="1"/>
<field name="invoice_id" /> <field name="invoice_id" />
<field name="invoice_state" /> <field name="invoice_state" />
<field name="invoice_amount_total" /> <field name="invoice_amount_total" />