Commit 3d3c67e2 by François C.

Merge branch 'dev_cooperatic' of…

Merge branch 'dev_cooperatic' of https://gl.cooperatic.fr/cooperatic-foodcoops/odoo into dev_cooperatic
parents 33377f5e e1eb9bac
...@@ -13,6 +13,21 @@ class ShiftTemplate(models.Model): ...@@ -13,6 +13,21 @@ class ShiftTemplate(models.Model):
_inherit = 'shift.template' _inherit = 'shift.template'
def _will_member_be_still_exempted_at_date(self, partner, rec_date):
answer = False
if partner.cooperative_state == "exempted":
#_logger.debug("%s is exempted now, but what about at %s", str(partner.id), str(rec_date))
rec_date = datetime.strptime(rec_date, '%Y-%m-%d')
for l in partner.leave_ids:
#_logger.debug("leave start end : %s %s", str(l.start_date), str(l.stop_date))
if (l.start_date is False or rec_date >= datetime.strptime(l.start_date, '%Y-%m-%d') and
l.stop_date is False or rec_date <= datetime.strptime(l.stop_date, '%Y-%m-%d')):
answer = True
#_logger.debug("Partner will be still exempted")
return answer
@api.model @api.model
def ng_create_shifts_from_template(self, instance=None, after=False, before=False): def ng_create_shifts_from_template(self, instance=None, after=False, before=False):
conf = self.env['ir.config_parameter'] conf = self.env['ir.config_parameter']
...@@ -87,20 +102,22 @@ class ShiftTemplate(models.Model): ...@@ -87,20 +102,22 @@ class ShiftTemplate(models.Model):
for attendee in ticket.registration_ids: for attendee in ticket.registration_ids:
state, strl_id = attendee._get_state(rec_date) state, strl_id = attendee._get_state(rec_date)
if state: if state:
vals = { # only register if attendee is not exempted when the event will occur
'partner_id': attendee.partner_id.id, if self._will_member_be_still_exempted_at_date(attendee.partner_id, rec_date) is False:
'user_ids': [(6, 0, template.user_ids.ids)], vals = {
'state': state, 'partner_id': attendee.partner_id.id,
'email': attendee.email, 'user_ids': [(6, 0, template.user_ids.ids)],
'phone': attendee.phone, 'state': state,
'name': attendee.name, 'email': attendee.email,
'shift_id': shift_id.id, 'phone': attendee.phone,
'shift_ticket_id': ticket_id.id, 'name': attendee.name,
'tmpl_reg_line_id': strl_id, 'shift_id': shift_id.id,
'template_created': True, 'shift_ticket_id': ticket_id.id,
} 'tmpl_reg_line_id': strl_id,
self.env['shift.registration'].with_context( 'template_created': True,
from_shift_template=True).create(vals) }
self.env['shift.registration'].with_context(
from_shift_template=True).create(vals)
@api.model @api.model
...@@ -115,9 +132,9 @@ class ShiftTemplate(models.Model): ...@@ -115,9 +132,9 @@ class ShiftTemplate(models.Model):
('week_list', '=', today.strftime('%a').upper()[0:2]), ('week_list', '=', today.strftime('%a').upper()[0:2]),
('last_shift_date', '<=', datetime.strftime(futur, "%Y-%m-%d"))] ('last_shift_date', '<=', datetime.strftime(futur, "%Y-%m-%d"))]
templates = self.env['shift.template'].search(filters) templates = self.env['shift.template'].search(filters)
# templates = self.env['shift.template'].search([('id', '=', 60)]) #templates = self.env['shift.template'].search([('id', '=', 123)])
for template in templates: for template in templates:
# _logger.info("Shift template = %s", str(template)) #_logger.debug("Shift template = %s", str(template))
self.ng_create_shifts_from_template( instance=template, self.ng_create_shifts_from_template( instance=template,
before=fields.Datetime.to_string( before=fields.Datetime.to_string(
datetime.today() + timedelta(days=shift_creation_days))) datetime.today() + timedelta(days=shift_creation_days)))
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Customization of Purchase process""", Customization of Purchase process""",
'description': """ 'description': """
Customization of Purchase process Customization of Purchase process & orders export method
""", """,
'author': "cooperatic", 'author': "cooperatic",
......
...@@ -40,3 +40,27 @@ class PurchaseOrder(models.Model): ...@@ -40,3 +40,27 @@ class PurchaseOrder(models.Model):
export_url += '/export/' + str(self.id) export_url += '/export/' + str(self.id)
requests.get(export_url) requests.get(export_url)
return res return res
@api.multi
def get_received_orders_between_dates(self, date_from, date_to):
res = {}
sql = """
SELECT po.name as id_po, sp.date_done, po.amount_untaxed, po.amount_total, po.state, rp.name as supplier_name
FROM purchase_order as po
LEFT JOIN stock_picking as sp ON po.name=sp.origin
LEFT JOIN res_partner as rp ON po.partner_id=rp.id
WHERE sp.date_done IS NOT NULL
AND sp.date_done >= '{date_from}'
AND sp.date_done <= '{date_to}'
ORDER BY sp.date_done ASC
"""
sql = sql.format(date_from=date_from, date_to=date_to)
try:
self.env.cr.execute(sql)
res["data"] = self.env.cr.dictfetchall()
except Exception as e:
res["error"] = str(e)
return res
...@@ -262,7 +262,6 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -262,7 +262,6 @@ odoo.define("pos_meal_voucher.screens", function (require) {
this.reset_input(); this.reset_input();
this.render_paymentlines(); this.render_paymentlines();
}, },
render_paymentmethods: function() { render_paymentmethods: function() {
var self = this; var self = this;
var methods = this._super.apply(this, arguments); var methods = this._super.apply(this, arguments);
...@@ -279,8 +278,24 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -279,8 +278,24 @@ odoo.define("pos_meal_voucher.screens", function (require) {
var paymentScreen = this.pos.gui.current_screen; var paymentScreen = this.pos.gui.current_screen;
var order = this.pos.get_order(); var order = this.pos.get_order();
if (
order.selected_paymentline.is_meal_voucher()
&& order.get_total_meal_voucher_eligible() == 0
) {
this.gui.show_popup("alert", {
'title': _t("Impossible de payer en titre restaurant"),
'body': _t("Aucun article du panier n'est éligible en titres restaurants (Montant éligible : 0€)."),
cancel: function() {
this.pos.get_order().remove_paymentline(order.selected_paymentline);
var paymentScreen = this.pos.gui.current_screen;
paymentScreen.reset_input();
paymentScreen.render_paymentlines();
}
});
return false;
}
if(order.selected_paymentline.is_meal_voucher() && order.selected_paymentline.is_dematerialized_meal_voucher()){ if(order.selected_paymentline.is_meal_voucher() && order.selected_paymentline.is_dematerialized_meal_voucher()){
var total_eligible = order.get_total_meal_voucher_eligible(); var total_eligible = order.get_total_meal_voucher_eligible();
var total_received = order.get_total_meal_voucher_received(); var total_received = order.get_total_meal_voucher_received();
...@@ -325,14 +340,8 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -325,14 +340,8 @@ odoo.define("pos_meal_voucher.screens", function (require) {
}, },
}); });
} }
}, },
render_paymentlines: function() { render_paymentlines: function() {
var self = this; var self = this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment