def _setup_widgets(self): # Salesperson combo salespersons = SalesPerson.get_active_salespersons(self.store) self.salesperson.prefill(salespersons) change_salesperson = sysparam.get_int('ACCEPT_CHANGE_SALESPERSON') if change_salesperson == ChangeSalespersonPolicy.ALLOW: self.salesperson.grab_focus() elif change_salesperson == ChangeSalespersonPolicy.DISALLOW: self.salesperson.set_sensitive(False) elif change_salesperson == ChangeSalespersonPolicy.FORCE_CHOOSE: self.model.salesperson = None self.salesperson.grab_focus() else: raise AssertionError # CFOP combo if sysparam.get_bool('ASK_SALES_CFOP'): cfops = CfopData.get_for_sale(self.store) self.cfop.prefill(api.for_combo(cfops)) else: self.cfop_lbl.hide() self.cfop.hide() self.create_cfop.hide() self._fill_clients_category_combo() self._setup_clients_widget() self._client_credit_set_visible(bool(self.client.read()))
def _setup_widgets(self): self._calc = CalculatorPopup(self.price, CalculatorPopup.MODE_SUB) self.sale.set_text(unicode(self.model.sale.identifier)) self.description.set_text(self.model.sellable.get_description()) self.original_price.update(self.model.base_price) for widget in [self.quantity, self.price]: widget.set_adjustment(gtk.Adjustment(lower=1, upper=MAX_INT, step_incr=1, page_incr=10)) self.reserved.set_adjustment(gtk.Adjustment(lower=0, upper=self.quantity_model.quantity, step_incr=1, page_incr=10)) first_page = self.tabs.get_nth_page(0) self.tabs.set_tab_label_text(first_page, _(u'Basic')) if not self.nfe_is_active: self.cfop_label.hide() self.cfop.hide() if not self._can_reserve(): self.reserved.hide() self.reserved_lbl.hide() # We populate this even if it's hidden because we need a default value # selected to add to the sale item cfop_items = CfopData.get_for_sale(self.store) self.cfop.prefill(api.for_combo(cfop_items)) self._setup_taxes() self._update_total()
def _setup_widgets(self): self.total.set_bold(True) idents = sorted(p.identifier for p in self.purchases) identifier = ', '.join(str(i) for i in idents) self.identifier.set_text(identifier) # TODO: Testar isso quando compras > 1 if len(self.purchases) == 1 and self.purchases[0].is_paid(): # This widgets would make the value of the installments change. for widget in (self.ipi, self.discount_value, self.icms_total, self.icms_st_total, self.secure_value, self.expense_value): widget.set_sensitive(False) # Only allow to edit the cfop if there is only one receiving for this invoice self.cfop.set_sensitive(bool(not self.visual_mode and self._receiving_order)) self._setup_transporter_entry() self._setup_freight_combo() cfops = CfopData.get_for_receival(self.store) self.cfop.prefill(api.for_combo(cfops)) self.table.set_focus_chain([self.invoice_hbox, self.invoice_key, self.cfop, self.transporter, self.freight_combo, self.notes_box, self.freight, self.ipi, self.icms_total, self.icms_st_total, self.discount_value, self.secure_value, self.expense_value])
def _setup_widgets(self): self._calc = CalculatorPopup(self.price, CalculatorPopup.MODE_SUB) self.sale.set_text(str(self.model.sale.identifier)) self.description.set_text(self.model.sellable.get_description()) self.original_price.update(self.model.base_price) self.price.set_adjustment(Gtk.Adjustment(lower=0, upper=MAX_INT, step_increment=1, page_increment=10)) unit = self.model.sellable.unit digits = QUANTITY_PRECISION if unit and unit.allow_fraction else 0 for widget in [self.quantity, self.reserved]: widget.set_digits(digits) widget.set_adjustment(Gtk.Adjustment(lower=0, upper=MAX_INT, step_increment=1, page_increment=10)) manager = get_plugin_manager() self.nfe_is_active = manager.is_any_active(['nfe', 'nfce']) if not self.nfe_is_active: self.cfop_label.hide() self.cfop.hide() if not self._can_reserve(): self.reserved.hide() self.reserved_lbl.hide() # We populate this even if it's hidden because we need a default value # selected to add to the sale item cfop_items = CfopData.get_for_sale(self.store) self.cfop.prefill(api.for_combo(cfop_items)) self._update_total() self.reserved.get_adjustment().set_upper(self.quantity_model.quantity)
def _setup_widgets(self): # Salesperson combo salespersons = SalesPerson.get_active_salespersons(self.store) self.salesperson.prefill(api.for_person_combo(salespersons)) change_salesperson = sysparam.get_int('ACCEPT_CHANGE_SALESPERSON') if change_salesperson == ChangeSalespersonPolicy.ALLOW: self.salesperson.grab_focus() elif change_salesperson == ChangeSalespersonPolicy.DISALLOW: self.salesperson.set_sensitive(False) elif change_salesperson == ChangeSalespersonPolicy.FORCE_CHOOSE: self.model.salesperson = None self.salesperson.grab_focus() else: raise AssertionError # CFOP combo if sysparam.get_bool('ASK_SALES_CFOP'): cfops = CfopData.get_for_sale(self.store) self.cfop.prefill(api.for_combo(cfops)) else: self.cfop_lbl.hide() self.cfop.hide() self.create_cfop.hide() self._fill_clients_category_combo() self._setup_clients_widget() self._client_credit_set_visible(bool(self.client.read()))
def _setup_widgets(self): self._calc = CalculatorPopup(self.price, CalculatorPopup.MODE_SUB) self.sale.set_text(unicode(self.model.sale.identifier)) self.description.set_text(self.model.sellable.get_description()) self.original_price.update(self.model.base_price) self.price.set_adjustment(gtk.Adjustment(lower=0, upper=MAX_INT, step_incr=1, page_incr=10)) unit = self.model.sellable.unit digits = QUANTITY_PRECISION if unit and unit.allow_fraction else 0 for widget in [self.quantity, self.reserved]: widget.set_digits(digits) widget.set_adjustment(gtk.Adjustment(lower=0, upper=MAX_INT, step_incr=1, page_incr=10)) manager = get_plugin_manager() self.nfe_is_active = manager.is_active('nfe') if not self.nfe_is_active: self.cfop_label.hide() self.cfop.hide() if not self._can_reserve(): self.reserved.hide() self.reserved_lbl.hide() # We populate this even if it's hidden because we need a default value # selected to add to the sale item cfop_items = CfopData.get_for_sale(self.store) self.cfop.prefill(api.for_combo(cfop_items)) self._update_total() self.reserved.get_adjustment().set_upper(self.quantity_model.quantity)
def setup_sellable_combos(self): self._fill_categories() self.edit_category.set_sensitive(False) cfops = CfopData.get_for_sale(self.store) self.default_sale_cfop.prefill(api.for_combo(cfops, empty='')) self.setup_unit_combo()
def _set_cfop_default(self, store, param_name, description, code): from stoqlib.domain.fiscal import CfopData if self.has_object(param_name): return data = self.get_object(store, param_name) if not data: data = CfopData(code=code, description=description, store=store) self.set_object(store, param_name, data)
def _create_cfop(self, key, description, code): from stoqlib.domain.fiscal import CfopData if self.get_parameter_by_field(key, CfopData): return data = self.store.find(CfopData, code=code).one() if not data: store = new_store() data = CfopData(code=code, description=description, store=store) store.commit(close=True) self._set_schema(key, data.id)
def _set_cfop_default(self, store, param_name, description, code): from stoqlib.domain.fiscal import CfopData if self.has_object(param_name): return data = self.get_object(store, param_name) if not data: # There is no unique code constraint in the cfop_data table! data = store.find(CfopData, code=code).any() if data is None: data = CfopData(code=code, description=description, store=store) self.set_object(store, param_name, data)
def test_getclient_sales(self): client = self.store.find(Client) assert not client.is_empty() client = client[0] CfopData(code=u'123', description=u'bla', store=self.store) branches = self.store.find(Branch) assert not branches.is_empty() people = self.store.find(SalesPerson) assert not people.is_empty() count_sales = client.get_client_sales().count() sale = self.create_sale() sale.client = client products = self.store.find(Product) assert not products.is_empty() product = products[0] sale.add_sellable(product.sellable) one_more_sale = client.get_client_sales().count() self.assertEquals(count_sales + 1, one_more_sale)
def _setup_widgets(self): # Salesperson combo salespersons = self.store.find(SalesPerson) self.salesperson.prefill(api.for_person_combo(salespersons)) if not sysparam.get_bool('ACCEPT_CHANGE_SALESPERSON'): self.salesperson.set_sensitive(False) else: self.salesperson.grab_focus() # CFOP combo if sysparam.get_bool('ASK_SALES_CFOP'): cfops = CfopData.get_for_sale(self.store) self.cfop.prefill(api.for_combo(cfops)) else: self.cfop_lbl.hide() self.cfop.hide() self.create_cfop.hide() self._fill_clients_category_combo() self._setup_clients_widget() self._client_credit_set_visible(bool(self.client.read()))
def _fill_cfop_combo(self): marker('Filling CFOPs') cfops = CfopData.get_for_sale(self.store) self.cfop.prefill(api.for_combo(cfops)) marker('Filled CFOPs')
def create_cfop_data(self): from stoqlib.domain.fiscal import CfopData return CfopData(store=self.store, code=u'123', description=u'test')
def testGetDescription(self): cfop = CfopData(code=u"2365", description=u"blabla", store=self.store) full_desc = cfop.get_description() self.assertEqual(full_desc, u"%s %s" % (u"2365", u"blabla"))
def _fill_cfop_combo(self): cfops = CfopData.get_for_sale(self.store) self.cfop.prefill(api.for_combo(cfops))
def apply_patch(store): # Creation of new column in stock_decrease table. # And added new Cfop to cfop_data table. store.execute("""ALTER TABLE stock_decrease ADD COLUMN cfop_id bigint REFERENCES cfop_data(id);""") # Default Cfop should be use in manual stock decrease. cfop_data = store.find(CfopData, code=u'5.949').one() if not cfop_data: cfop_data = CfopData(store=store, code=u"5.949", description=u"Outra saída de mercadoria ou " u"prestação de serviço não " u"especificado") # Adjusting existing manuals outputs for stock_decrease in store.find(StockDecrease): stock_decrease.cfop = cfop_data retentions = store.execute(""" SELECT id, quantity, reason, retention_date, product_id, cfop_id FROM product_retention_history ORDER BY id;""").get_all() # Without retentions, there is no need to create user and employee # variables. if len(retentions): # Default user for migration user = get_admin_user(store) if user is None: users = Person.iselectBy(IUser, is_active=True, store=store).order_by(Person.id) user = users[0] # Default employee for migration employee = IEmployee(user.person, None) if employee is None: employees = Person.iselectBy(IEmployee, is_active=True, store=store).order_by(Person.id) employee = employees[0] default_branch = sysparam().MAIN_COMPANY notes = _(u"Stock decrease imported from old retention.") history = store.execute(""" SELECT id, quantity_retained, sellable_id, branch_id FROM product_history WHERE quantity_retained is not null ORDER BY id;""").get_all() for i in range(len(retentions)): ret = retentions[i] hist = history[i] product = Product.get(ret[4], store=store) branch_id = hist[3] if ret[1] != hist[1] or product.sellable.id != hist[2]: branch_id = default_branch.id decrease = StockDecrease(store=store, confirm_date=ret[3], status=StockDecrease.STATUS_CONFIRMED, reason=ret[2], notes=notes, responsible=user, removed_by=employee, branch_id=branch_id, cfop_id=ret[5]) decrease_item = StockDecreaseItem(store=store, quantity=ret[1], sellable=product.sellable) decrease.add_item(decrease_item) store.remove(hist[0]) ProductHistory(branch_id=branch_id, sellable=product.sellable, quantity_decreased=decrease_item.quantity, decreased_date=decrease.confirm_date, store=store) store.execute("""ALTER TABLE product_history DROP COLUMN quantity_retained;""") store.execute("DROP TABLE product_retention_history;")
def create_model(self, store): return CfopData(code=u"", description=u"", store=store)