Browse Source

Merge branch '9.0' of https://github.com/beescoop/Obeesdoo into 9.0

pull/14/head
EliseDup 8 years ago
parent
commit
b67d9734fd
  1. 2
      beesdoo_base/__openerp__.py
  2. 10
      beesdoo_base/data/default_contact.xml
  3. 16
      beesdoo_base/models/partner.py
  4. 29
      beesdoo_base/views/partner.xml
  5. 2
      beesdoo_base/wizard/__init__.py
  6. 2
      beesdoo_base/wizard/member_card.py
  7. 21
      beesdoo_base/wizard/partner.py
  8. 2
      beesdoo_base/wizard/views/member_card.xml
  9. 22
      beesdoo_base/wizard/views/partner.xml
  10. 3
      beesdoo_purchase/models/__init__.py
  11. 14
      beesdoo_purchase/models/purchase.py
  12. 3
      import_odoo/__openerp__.py
  13. 2
      import_odoo/security/ir.model.access.csv
  14. 2
      requirement.txt

2
beesdoo_base/__openerp__.py

@ -22,5 +22,7 @@
'security/ir.model.access.csv',
'views/partner.xml',
'wizard/views/member_card.xml',
'wizard/views/partner.xml',
'data/default_contact.xml',
],
}

10
beesdoo_base/data/default_contact.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record model="res.partner" id="commande_beescoop">
<field name="name">commande@bees-coop.be</field>
<field name="email">commande@bees-coop.be</field>
<field name="active">True</field>
</record>
</data>
</odoo>

16
beesdoo_base/models/partner.py

@ -16,6 +16,7 @@ class Partner(models.Model):
barcode = fields.Char(compute="_get_bar_code", string='Barcode', store=True)
parent_barcode = fields.Char(compute="_get_bar_code", string='Parent Barcode', store=True)
member_card_ids = fields.One2many('member.card', 'partner_id')
country_id = fields.Many2one(required=True, default=lambda self: self.env.ref('base.be'))
member_card_to_be_printed = fields.Boolean('Print BEES card?')
last_printed = fields.Datetime('Last printed on')
@ -74,4 +75,17 @@ class Partner(models.Model):
cr.execute("UPDATE res_partner set last_name = name where last_name IS NULL")
return res
@api.multi
def _new_eater(self, surname, name, email):
partner_data = {
'name' : surname + " "+ name,
'last_name' : name,
'first_name' : surname,
'is_customer' : True,
'eater' : 'eater',
'parent_eater_id' : self.id,
'parent_id' : self.id,
'email' : email,
'country_id' : self.country_id.id
}
return self.env['res.partner'].create(partner_data)

29
beesdoo_base/views/partner.xml

@ -7,6 +7,13 @@
<field name="target">new</field>
</record>
<record model="ir.actions.act_window" id="action_eater_wizard">
<field name="name">New Eater</field>
<field name="res_model">eater.new.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.ui.view" id="beesdoo_partner_form_view">
<field name="name">beesdoo.partner.form.view</field>
<field name="model">res.partner</field>
@ -20,12 +27,11 @@
default_focus="1" />
</field>
<field name="website" position="after">
<field name="eater"
attrs="{'invisible': [('company_type', '=', 'company')]}" />
<field name="eater" attrs="{'invisible': [('customer', '=', False)]}" />
<field name="parent_eater_id" attrs="{'invisible' : [('eater', '!=', 'eater')]}" />
</field>
<xpath expr="//notebook" position="inside">
<page string="Member Cards"
<page string="Member Card"
attrs="{'invisible': ['|', ('customer', '=', False), ('eater', '!=', 'worker_eater')]}">
<separator string="Printing" />
<group>
@ -34,6 +40,10 @@
</group>
<separator string="Eaters" />
<field name="child_eater_ids" widget="many2many_tags" />
<group>
<button string="New Eater" name="%(action_eater_wizard)d"
type="action" />
</group>
<separator string="Cards" />
<field string="Cards" name="member_card_ids">
<tree editable="bottom">
@ -52,21 +62,28 @@
</page>
</xpath>
<field name="barcode" position="attributes">
<attribute name="attrs">{'invisible' : [('eater', '!=', 'worker_eater')]}</attribute>
<attribute name="attrs">{'invisible' : [('eater', '!=',
'worker_eater')]}
</attribute>
</field>
<field name="barcode" position="after">
<field name="parent_barcode" attrs="{'invisible' : [('eater', '!=', 'eater')]}" />
</field>
<button name="toggle_active" position="attributes">
<attribute name="groups" />
</button>
</field>
</record>
<!-- S022 : By default a supplier should be a company -->
<record id="base.action_partner_supplier_form" model="ir.actions.act_window">
<field name="context">{ 'search_default_supplier': 1,
<field name="context">{
'search_default_supplier': 1,
'default_customer': 0,
'default_supplier': 1,
'default_is_company' : True,
'default_company_type' : 'company', }
'default_company_type' : 'company',
}
</field>
</record>
</odoo>

2
beesdoo_base/wizard/__init__.py

@ -1,2 +1,2 @@
import member_card
import member_card, partner

2
beesdoo_base/wizard/member_card.py

@ -21,7 +21,7 @@ class NewMemberCardWizard(models.TransientModel):
client = self.partner_id.sudo()
client._deactivate_active_cards()
client._new_card(self.new_comment, self.env.uid, barcode=self.force_barcode)
client.member_card_to_be_printed = True
class RequestMemberCardPrintingWizard(models.TransientModel):

21
beesdoo_base/wizard/partner.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class NewEaterWizard(models.TransientModel):
"""
A transient model for the creation of a eater related to a worker.
"""
_name = 'eater.new.wizard'
def _get_default_partner(self):
return self.env.context['active_id']
first_name = fields.Char('First Name', required=True)
last_name = fields.Char('Last Name', required=True)
email = fields.Char('Email')
partner_id = fields.Many2one('res.partner', default=_get_default_partner)
@api.one
def create_new_eater(self):
self.partner_id._new_eater(self.first_name, self.last_name, self.email)

2
beesdoo_base/wizard/views/member_card.xml

@ -10,7 +10,7 @@
<field name="force_barcode" />
</group>
<separator string="Reason" />
<field name="new_comment" string="Raison" editable="True" />
<field name="new_comment" string="Reason" editable="True" />
<field name="partner_id" invisible="1" />
<footer>
<button type="object" name="create_new_card" string="Create"

22
beesdoo_base/wizard/views/partner.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- New eater generation wizard -->
<record id="Eater Wizard" model="ir.ui.view">
<field name="name">New Eater Wizard</field>
<field name="model">eater.new.wizard</field>
<field name="arch" type="xml">
<form string="Create a new eater">
<group>
<field name="first_name" />
<field name="last_name" />
<field name="email" />
</group>
<footer>
<button type="object" name="create_new_eater" string="Create"
class="oe_highlight" />
<button special="cancel" string="Cancel" />
</footer>
</form>
</field>
</record>
</odoo>

3
beesdoo_purchase/models/__init__.py

@ -1,2 +1 @@
# -*- coding: utf-8 -*-
import purchase

14
beesdoo_purchase/models/purchase.py

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from openerp import models, api
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
@api.model
def create(self, vals):
purchase_order = super(PurchaseOrder, self).create(vals)
command_contact = self.env.ref('beesdoo_base.commande_beescoop', raise_if_not_found=False)
# We do not need to update sale_order.mail_followers_ids, the link is automatic ?!
if command_contact:
self.env['mail.followers'].create({'res_model' : 'purchase.order', 'res_id' : purchase_order.id, 'partner_id' : command_contact.id})
return purchase_order

3
import_odoo/__openerp__.py

@ -31,7 +31,8 @@
'website': 'https://github.com/tfrancoi/',
'depends': ['base', 'import_base'],
'data': [
'view/connector.xml'
'view/connector.xml',
'security/ir.model.access.csv',
],
'test': [], #TODO provide test
'installable': True,

2
import_odoo/security/ir.model.access.csv

@ -0,0 +1,2 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_import_odoo_connection,access_import_odoo_connection,model_import_odoo_connection,,1,0,0,0

2
requirement.txt

@ -0,0 +1,2 @@
pycoda
openerp-client-lib
Loading…
Cancel
Save